Templates Module

Templates Functions & Variables

The Templates Module features the following functions:


templates.bootstrap(type) - back to top

This function will return the raw Mustache-compliant HTML template from $.fn.blockstrap.snippets[key].

- back to top


templates.filter(html, placeholders, replacements) - back to top

This function will return the sent html after having replaced all instances of each item in the placeholders array with the corresponding replacement found with the replacements array. Please note that the placeholder should be placed in-between two curly brackets within the html and that if no placeholders or replacements are provided it will use the following placeholders array:

var placeholders = [
    'urls.root', 
    'user.name',
    'vars.txid',
    'vars.key',
    'tx.size',
    'tx.time',
    'tx.block',
    'tx.input',
    'tx.output',
    'tx.fees',
    'address.tx_count',
    'address.balance'
];

And the following replacements array:

var replacements = [
    $.fn.blockstrap.settings.base_url,
    name,
    txid,
    key,
    tx.size + ' (Bytes)',
    tx.time,
    tx.block,
    parseInt(tx.input) / 100000000 + ' ' + tx_blockchain,
    parseInt(tx.output) / 100000000 + ' ' + tx_blockchain,
    parseInt(tx.fees) / 100000000 + ' ' + tx_blockchain,
    account.tx_count,
    parseInt(account.balance) / 100000000 + ' ' + add_blockchain
];

Assuming you were viewing the DEMO WALLET, this html:

<a href="{{urls.root}}">Homepage</a>

Would become:

<a href="http://demo.blockstrap.com/framework/v0.5/">Homepage</a>

- back to top


templates.process(data, html) - back to top

This function takes the provided data, runs it through core.filter, combines it with the html variable using mustache templating and then filters the rendered results using template.filter before returning the final output.

- back to top


templates.render(slug, callback, refresh) - back to top

This function is used to render page content by using the slug to collect data and HTML as follows:

var $bs = blockstrap_functions;
var data_url = 'themes/' + bs.settings.theme + '/' + bs.settings.data_base + slug;
var html_url = 'themes/' + bs.settings.theme + '/' + bs.settings.html_base + slug;

It then filters the collected data ($.fn.blovkstrap.core.filter), combines it with the HTML using mustache templating and then filters the rendered results using template.filter, at which point if refresh is set to true or the current slug is the homepage of the application, the current DOM will be replaced with new content.

If the refresh is not set or the current slug is not the homepage, the application will instead update the content by using $.fn.blockstrap.settings.content_id.

- back to top


  1. Related Articles
  2. Back to Modules
  3. Accounts
  4. API
  5. Buttons
  6. Contacts
  7. Blockchains
  8. Data
  9. Filters
  10. Forms
  11. Security
  12. Styles
  13. Templates
  14. Table of Contents