think-template-twig

v1.0.1
twig template adapter for ThinkJS
thinkjs twig template

think-template-twig

Twig template adapter for ThinkJS

Install

npm install think-template-twig

How to use

register adapter

import TwigAdapter from 'think-template-twig';
think.adapter('template', 'twig', TwigAdapter);

add above code in bootstrap file, like src/common/bootstrap/adapter.js.

change view type

change view type in file src/common/config/view.js:

export default {
  type: 'twig',
  adapter: {
  twig: { //twig options
  	 //set prerender function if you want extend your twig template
  	 prerender(Twig, templateFile) {
      Twig.extendFunction('repeat', (value, times) => new Array(times+1).join(value));

      //more custom see
      //https://github.com/justjohn/twig.js/wiki/Extending-twig.js
      //https://github.com/justjohn/twig.js/wiki/Extending-twig.js-With-Custom-Tags
      }
    }
  }
}
npm i think-template-twig

Metadata

  • MIT
  • Whatever
  • lizheming
  • released 3/2/2016

Downloads

Maintainers