Ideas for templating with blockchain content

Let's have a shared way of thinking about engaging templating engines for content on the blockchain.

This document is meant to be an inspiration for people wanting to apply templating engines for content hosted on the blockchain. The text can be referred to as the "B://emplate" idea (pronounced bemplate) and should be seen as a common footstep to make future implementation more aligned. Please share inputs and comments.

Introduction

Templating is a common way of merging data with structure. Different templating engines have different syntax and options for logic, but a shared feature is that they have source data in a structured way and a template for using those data. The B://emplate document describes a philosophy of interacting with templating engines for content stored on the blockchain. Please note that no specific templating engine is suggested or recommended.

In the following, we will use main data object to refer to the data context in which a template engine will run.

Different models

Depending on the use case different models might be suitable.

Model A

Apoint data and template

Model A of the B://emplate idea will let clients who request content from a transaction with a specific bitcom namespace be presented with the result from running the templating engine engine using template and data to get the final result.

It could, for example, be done with transactions having the namespace 1GQuCczfJrvQqK9Vr64BQ8zJ9b7fiXq6Fg and 3 arguments: 1) a string with engine name, 2) A transaction ID targeting a transaction with the template and 3) A transaction ID targeting the transaction with data.

Model B

Apoint data from template metadata

Model B of the B://emplate idea will let clients who request content from a B:// transaction with a specific bitcom namespace appended be presented with the content generated by running the templating engine engine using data as data and content from the current transaction as the template.

It could, for example, be done by adding a | after the normal B:// tags followed by the 1NHGwK36T4BUVxrCs3GVf5Qrax3Sf2z2Bm namespace subsided by two arguments: 1) A string named engine and 2) A transaction ID targeting data.

Model C

Apoint template from data metadata

Model C of the B://emplate idea will let clients who request content from a B:// transaction with a specific bitcom namespace appended be presented with the content generated by running the templating engine engine using template as template and content from the current transaction as data.

It could, for example, be done by adding a | after the normal B:// tags followed by the 15SyJjP3VTaVWNEces7syqYeSjTF2kU3mq namespace subsided by two arguments: 1) A string named engine and 2) A transaction ID targeting template while using data as a HJSON parsed version of the content of the current transaction.

Model D

Pull multiple data from within template

Model D of the B://emplate idea will let content from a transaction be subject to a specific templating engine if a specific string was part of the content while the data context is derived from specific tags referencing data in othe rtransactions.

This could, for example, be done by letting content that contains the string {{engineName=B://}} be subject to the templating engine engineName (if supported) by having the current content as a template and the data context built up by letting each {{zyx=B://[TX]}} add a property to data named xyz containing the HJSON parsed content of the transaction TX (or a string with all content if the parse fails)

Implementations

Known implementations inspired by the ideas in the B://emplate document:


Please share inputs and comments.