Server Template engine for meteor
Simple API to use the meteor blaze engine server side.
Usage
First import the ServerTemplate module. Then you can use its render function by passing the template as a string together with the data as parameters for this function. You can also pass helper functions as a third parameter.
1import { ServerTemplate } from 'meteor/felixble:server-templates' 2 3let renderedHtml = ServerTemplate.render( 4 "Hallo {{name}}, sum: {{add 3 5}}", /* Template */ 5 {name: "felix"}, /* data object */ 6 {add: function(val1, val2) { return val1 + val2 }} /* object with helper functions */ 7); 8 9console.log(renderedHtml); /* Output: Hello felix, sum 8 */
Loading the template from a file
Meteor provides the global function Assets.getText(path) which loads a text file from the private folder and returns its content as a string. So you can store your templates under the private folder as simple html files and load them with the Assets.getText() function.