# meta-templater **Repository Path**: mirrors_TrySound/meta-templater ## Basic Information - **Project Name**: meta-templater - **Description**: node.js custom template parser - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-26 - **Last Updated**: 2026-01-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # meta-templater [![Join the chat at https://gitter.im/TrySound/meta-templater](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/TrySound/meta-templater?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) Flexible templates parser inspired by [gulp-file-include](https://github.com/coderhaoxin/gulp-file-include). ## Installation ``` $ npm i meta-templater ``` ## Theory Template has three types of constructions: ### var `//= var_name` Where `//=` is prefix and suffix is empty ### fn `//= include[]` Where `include` is `fn` name and `[]` is argument js object (array) ### op `//= print ( content )` `//= each[] ()` Where arguments is optinal and `()` is body of `op` ## Initialize compile.js ```js var MT = require('meta-templater'), fs = require('fs'); var result = new MT().build(fs.readFileSync('src/index.html', 'utf-8'), { param1: true, param2: 'John' }); fs.writeFileSync('dist/index.html', result, 'utf-8'); ``` ## Examples ### Condition Handler index.html ```html //= if[data.voice] (
Hello, //= name
) ``` ### Include Handler index.html ```html //= include['head.html', {title: 'Page Title'}] //= include['header.html'] //= include['content-main.html'] //= include['footer.html'] ``` head.html ```html //= title ``` ## API ### new MT(options); Initialize templater #### options.prefix Type: `String` Default: `//=` #### options.suffix Type: `String` Default: `` #### options.open Type: `String` Default: `(` #### options.close Type: `String` Default: `)` ### Methods #### addFn(name, handler); #### addOp(name, handler); ### Handler `this` methods #### build(input || body, data) #### flatten(input || body) ##License [The MIT License (MIT)](LICENSE) Copyright © 2015 Bogdan Chadkin