{"bugs":{"url":"https://github.com/kof/jqtpl/issues"},"dist":{"shasum":"e29db19052623b60efd354f8b887f4e84888ba9d","tarball":"https://registry.npmjs.org/jqtpl/-/jqtpl-2.0.16rc1.tgz","integrity":"sha512-JfB/xjUIHbF8wp5jd6IZxnnxvTwFSehGwzGAety9q1Wy8B1uxGBTjrbZ0DxAqwsHm3mtUsqXnoj2232e5E3mNw==","signatures":[{"sig":"MEYCIQDEUrNklu4JAntLkU+6QSsdPngdCADgqOD+Pv1oqh744QIhALZoEb1oXKD8ISO72FkK+XHU1jMb+meZ1f/ddYggz9ba","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"name":"jqtpl","_from":".","author":{"name":"Oleg Slobodskoi","email":"oleg008@gmail.com"},"readme":"## A template engine for nodejs, browser and any other javascript environment.\n\n- Logic-less.\n- Extendable - implement your own tags.\n- Html escaped per default.\n\n### Originally started as a port of jquery templates.\n\nhttp://github.com/jquery/jquery-tmpl\n\nhttp://api.jquery.com/category/plugins/templates/\n\n**Now compatibility to the original engine is dropped as jquery-tmpl is not any more developed.**\n\n### Installation\n\t$ npm i jqtpl\n    $ make test\n\n## Template API\n\n### ${}, {{=}} print variable, array or function (escaped)\n\n- Print variable\n\n    \t// tpl\n        <div>${a}</div>\n    \t// code\n        jqtpl.render(tpl, {a:123});\n        // output\n        <div>123</div>\n\n- Print array\n\n        //tpl\n        <div>${a}</div>\n        // code\n        jqtpl.render(tpl, [{a:1},{a:2},{a:3}]);\n        // output\n        <div>1</div><div>2</div><div>3</div>\n\n- Print automatically detected function\n\n        // tpl\n        <div>${a}</div>\n        // code\n        jqtpl.render(tpl, {\n            a: function() {\n                return 1 + 5;\n           }\n        });\n        //output\n        <div>6</div>\n\n### {{if}} and {{else}}\n\n\t// tpl\n    {{if a == 6}}\n        <div>${a}</div>\n    {{else a == 5}}\n    \t<div>5</div>\n    {{else}}\n        <div>a is not 6 and not 5</div>\n    {{/if}}\n\n\t// code\n    jqtpl.render(tpl, {a:6});\n\n\t// output\n    <div>6</div>\n\n\t// code\n    jqtpl.render(tpl, {a:5});\n\n\t// output\n    <div>a is not 6</div>\n\n### {{each}} looping.\n\n\t// tpl\n    {{each(name, i) names}}\n        <div>${i}.${name}</div>\n    {{/each}}\n\n    // alternative syntax\n\t{{each names}}\n\t\t<div>${$index}.${$value}</div>\n\t{{/each}}\n\n\t// code\n    jqtpl.render(tpl, {names: ['A', 'B']});\n\n\t// output\n    <div>0.A</div><div>1.B</div>\n\n### {{html}} -  print unescaped html.\n\n\t// tpl\n    <div>{{html a}}</div>\n\n\t// code\n    jqtpl.render(tpl, {a:'<div id=\"123\">2</div>'});\n\n\t// output\n    <div><div id=\"123\">2</div></div>\n\n\n### {{!}} - comments.\n\n\t// tpl\n    <div>{{! its a comment}}</div>\n\n\t// code\n    jqtpl.render(tpl);\n\n\t// output\n    <div></div>\n\n### {{partial}} - subtemplates.\n\nRender subtemplates by passing a template string, template name or file name (serverside).\n\n**Note: passing json object with 2 curly brackets without any separation will break the engine: {{partial({a: {b: 1}}) 'mypartial'}}**\n\n\t// tpl\n    <div>{{partial({name: 'Test'}) '${name}'}}</div>\n    <div>{{partial 'myTemplate'}}</div>\n    <div>{{partial 'myTemplate.html'}}</div>\n\n\t// code\n    jqtpl.render(tpl);\n\n\t// output\n    <div>Test</div>\n\n\n### {{verbatim}} tag\n\nSkip a part of your template - leave it in original on the same place but without \"verbatim\" tag. If you render the result as a template again - it will be rendered.\n\nThe use case is to be able to render the same template partially on the server and on the client. F.e. a layout template can contain variables which needs to be rendered on the server and templates which need to be rendered on the client.\n\n    // mytemplate.html\n    <div>my name is ${name}</div>\n    {{verbatim}}\n    <script id=\"my-template\">\n        <div>your name is ${userName}</div>\n    </script>\n    {{/verbatim}}\n\n    // code\n    res.render('myaction', {name: 'Kof'});\n\n    // output\n    <div>my name is Kof</div>\n    <script id=\"my-template\">\n        <div>your name is ${userName}</div>\n    </script>\n\n\n## Engine API\n\n### require the module\n    var jqtpl = require('jqtpl');\n\n### jqtpl.render(markup, [data]);\n\nCompile and render a template. It uses `jqtpl.template` method. Returns a rendered html string.\n\n- `markup` html code or precompiled template name.\n- `data` optional object or array of data.\n\n### jqtpl.compile(markup, [name])\n\nCompile and cache a template string. Returns a `render` function which can be called to render the template, see `jtpl.render`.\n\n- `markup` html string.\n- `name` optional template name, if no name is passed - markup string will be used as a name.\n\n        // tpl\n        <div>${a}</div>\n\n        // code\n\n        // precompile an cache it\n        jqtpl.compile(tpl, 'myTemplate');\n\n        // render user a name\n        jqtpl.render('myTemplate', {a:1});\n\n        // delete the template from cache\n        delete jqtpl.cache['myTemplate'];\n\n        // output\n        <div>1</div>\n\n### jqtpl.cache\n\nA map of compiled templates.\n\n- `key` - template name or markup string.\n- `value` - compiled template function.\n\n### jqtpl.$\n\nA namespace for global helper functions, which can be used in every template.\n\n## Express specific stuff\n\n**Note: express will cache all templates in production!**\n\n### Usage\n\n    app.set('views', '/path/to/the/views/dir');\n    app.set('view engine', 'html');\n    app.set('layout', true);\n    app.engine('html', require('jqtpl').__express);\n\n### {{layout}} tag\n\nUsing layout tag in a view it is possible to define a layout within this view.\n\n\t// mylayout.html\n\t<html>\n\t{{html body}}\n    </html>\n\n    // myview.html\n    {{layout 'mylayout'}}\n\t<div>myview</div>\n\n    // myview1.html\n    {{layout({a: 1}) 'mylayout'}}\n    <div>myview1</div>\n\n    // output\n    <html>\n\t<div>myview</div>\n    </html>\n\n## Licence\n\nSee package.json\n","engines":{"node":"*"},"_npmUser":{"name":"kof","email":"oleg008@gmail.com"},"keywords":["template","engine","jquery","jquery-tmpl","logic-less"],"licenses":[{"url":"http://www.opensource.org/licenses/mit-license.php","type":"MIT"}],"repository":{"url":"http://github.com/kof/jqtpl.git","type":"git"},"_npmVersion":"1.2.32","description":"A template engine for nodejs, browser and any other javascript environment","maintainers":[{"name":"kof","email":"oleg008@gmail.com"}],"dependencies":{"underscore":"1.4.x"},"readmeFilename":"readme.md","devDependencies":{"qunit":"0.5.x","express":"3.0.x","request":"2.9.x"},"_id":"jqtpl@2.0.16-rc1","version":"2.0.16-rc1"}