1.0.0 • Published 5 years ago

@inst-cli/template v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

MIT license


@inst-cli/template

A fast and simple template engine with variables, conditionals, and inline code blocks

Installation

npm i @inst-cli/template

yarn add @inst-cli/template

Usage

import compile from '@inst-cli/template'
let tpl = compile(`
  Hello, <:name:>
  
  <:if lastName:> 
    Is "<:lastName:>" really your last name?
  <:elif lastName === 'Smith':>
    Why do you have such a boring last name?
  <:else:>
    Y u no have last name?
  <:fi:>
    
  <:(
    value += "inline code ";
    
    for (let i = 0; i < vars.words.length; i++) {
      value += vars.words[i] + " ";
    }
  ):>
`)

tpl({name: 'jared', lastName: 'lunde', words: ['is', 'pretty', 'neat']})
//
//  Hello, jared
//  
//   
//    Is "lunde" really your last name?
//  
//    
//  inline code is pretty neat 
//

LICENSE

MIT