{"_id":"4p_template","_rev":"12-9a43242fc7160ddfa0acc8f6edc54cb8","name":"4p_template","description":"A template Engine for Express/NodeJs","dist-tags":{"latest":"0.4.1"},"versions":{"0.3.0":{"name":"4p_template","version":"0.3.0","keywords":["template"],"description":"A template Engine for Express/NodeJs","repository":{"type":"git","url":"https://github.com/mkdgs/4p_jstemplate.git"},"main":"nodejs_4p_template.js","dependencies":{"jsdom":"1.3.1","jquery":"2.1.1"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"mkdgs","email":"mickael.desgranges@gmail.com","url":"http://mkdgs.fr"},"license":"Cecill-B (french BSD-like)","bugs":{"url":"https://github.com/mkdgs/4p_jstemplate/issues"},"_id":"4p_template@0.3.0","_shasum":"9c31dfa0ec94f41afea002fc887ac273fbaea7bb","_from":".","_npmVersion":"1.4.21","_npmUser":{"name":"mkdgs","email":"mickael.desgranges@gmail.com"},"maintainers":[{"name":"mkdgs","email":"mickael.desgranges@gmail.com"}],"dist":{"shasum":"9c31dfa0ec94f41afea002fc887ac273fbaea7bb","tarball":"https://registry.npmjs.org/4p_template/-/4p_template-0.3.0.tgz","integrity":"sha512-KWTOTsxQFA0fj05VvNfU+JRyhthDII9AqLcH09gCjpuhwasnp5u5EdUPd4H/Mk8YDEQ0IifrRpoPayveHznkRg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICnKT5zQg6xch9P/Yk+DGa0KHX+k7YiXartbnD3LexU/AiAZI1f1gtqUn2UqzE1AIuHRNw3vFzkLaIt9K+kVVRdB7w=="}]}},"0.3.1":{"name":"4p_template","version":"0.3.1","keywords":["template"],"description":"A template Engine for Express/NodeJs","repository":{"type":"git","url":"https://github.com/mkdgs/4p_jstemplate.git"},"main":"nodejs_4p_template.js","dependencies":{"jsdom":"1.3.1","jquery":"2.1.1"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"mkdgs","email":"mickael.desgranges@gmail.com","url":"http://mkdgs.fr"},"license":"Cecill-B (french BSD-like)","bugs":{"url":"https://github.com/mkdgs/4p_jstemplate/issues"},"_id":"4p_template@0.3.1","_shasum":"40dba20e4ec06cdb86141ee045184d111e4252a4","_from":".","_npmVersion":"1.4.21","_npmUser":{"name":"mkdgs","email":"mickael@mkdgs.fr"},"maintainers":[{"name":"mkdgs","email":"mickael.desgranges@gmail.com"}],"dist":{"shasum":"40dba20e4ec06cdb86141ee045184d111e4252a4","tarball":"https://registry.npmjs.org/4p_template/-/4p_template-0.3.1.tgz","integrity":"sha512-hg6t44xk9TZ9EsCJw1xlP3euY+hwLmQuq43BvsGnmVY/VAiLYPwEtNjYcD83f7e7DHa/T0WbXoYveej57Ir6fg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFWLzf7CWSvRWckdk35P2DNSykx+cgHgfTNs7lzJDYgkAiEAib2+M61AtpMo1NP9OI/P/Qzx170+aEQNmyMQLyxKtWI="}]}},"0.3.2":{"name":"4p_template","version":"0.3.2","keywords":["template"],"description":"A template Engine for Express/NodeJs","repository":{"type":"git","url":"https://github.com/mkdgs/4p_jstemplate.git"},"main":"nodejs_4p_template.js","dependencies":{"jsdom":"1.3.1","jquery":"2.1.1"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"mkdgs","email":"mickael.desgranges@gmail.com","url":"http://mkdgs.fr"},"license":"Cecill-B (french BSD-like)","bugs":{"url":"https://github.com/mkdgs/4p_jstemplate/issues"},"_id":"4p_template@0.3.2","_shasum":"71971cfef776dd405855fa5269858e2f19e9f5b8","_from":".","_npmVersion":"1.4.21","_npmUser":{"name":"mkdgs","email":"mickael@mkdgs.fr"},"maintainers":[{"name":"mkdgs","email":"mickael.desgranges@gmail.com"}],"dist":{"shasum":"71971cfef776dd405855fa5269858e2f19e9f5b8","tarball":"https://registry.npmjs.org/4p_template/-/4p_template-0.3.2.tgz","integrity":"sha512-BYO4K/jhESuA4YVS+C4KgJsGz4hCocyEmUrP+j884XiSKoYmp+G4xsKRS7Zlv99hFAYoXlx1ioGgccr0p36RKg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICqxtEZLmS6NpF4f05+4bECSrgeuJsKuHO3pCz8hqxEYAiA1TYFOgfneh73d6EUtlkRGJbgruU3p1mN5zWyiASUzzg=="}]}},"0.4.0":{"name":"4p_template","version":"0.4.0","keywords":["template"],"description":"A template Engine for Express/NodeJs","repository":{"type":"git","url":"https://github.com/mkdgs/4p_jstemplate.git"},"main":"nodejs_4p_template.js","dependencies":{"jsdom":"1.3.1","jquery":"2.1.1"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"mkdgs","email":"mickael.desgranges@gmail.com","url":"http://mkdgs.fr"},"license":"Cecill-B (french BSD-like)","bugs":{"url":"https://github.com/mkdgs/4p_jstemplate/issues"},"_id":"4p_template@0.4.0","_shasum":"d25f5af554eba798f8ff977d1c0a72005ee0efcb","_from":"./","_npmVersion":"1.4.21","_npmUser":{"name":"mkdgs","email":"mickael@mkdgs.fr"},"maintainers":[{"name":"mkdgs","email":"mickael.desgranges@gmail.com"}],"dist":{"shasum":"d25f5af554eba798f8ff977d1c0a72005ee0efcb","tarball":"https://registry.npmjs.org/4p_template/-/4p_template-0.4.0.tgz","integrity":"sha512-Liy20nbGWidmcB/SxHfCAH9B9alZt4rU9zZgATye/Nbb5QIsQYy4e84n3chU3DjqIUFoC88pDipz/DTzsx20lw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCOVhMbKek7FFkGjlCrpTXs6DAAAGMZDQKg4Rb56vm+5AIhAMz/zk6ntSELbOevI9q4hgurs8/wwLOFh47IHuBXEomA"}]}},"0.4.1":{"name":"4p_template","version":"0.4.1","keywords":["template"],"description":"A template Engine for Express/NodeJs","repository":{"type":"git","url":"https://github.com/mkdgs/4p_jstemplate.git"},"main":"nodejs_4p_template.js","dependencies":{"jsdom":"1.3.1","jquery":"2.1.1"},"scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"author":{"name":"mkdgs","email":"mickael.desgranges@gmail.com","url":"http://mkdgs.fr"},"license":"Cecill-B (french BSD-like)","bugs":{"url":"https://github.com/mkdgs/4p_jstemplate/issues"},"_id":"4p_template@0.4.1","_shasum":"81f16832caa0ec8d1926ddee6ade9a9cfa9bdaca","_from":"./","_npmVersion":"1.4.21","_npmUser":{"name":"mkdgs","email":"mickael@mkdgs.fr"},"maintainers":[{"name":"mkdgs","email":"mickael.desgranges@gmail.com"}],"dist":{"shasum":"81f16832caa0ec8d1926ddee6ade9a9cfa9bdaca","tarball":"https://registry.npmjs.org/4p_template/-/4p_template-0.4.1.tgz","integrity":"sha512-fAR2aP/wLHpRJbPWVqeQSh2/JPXl0pzdFlGx4fzCqofr5AZwMn9jOaOgPoOuEU+d8uFdsm0IvQK+TKtPyi3wfw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCH2wzz2arSMDZyb6hA+4oHvA3G+o1nNw54OXsO6lrW6gCIQDJCfIq59UffLaHFaa7WpFf7D+NMfTkmla1iWAglyEeZg=="}]}}},"readme":"4p_jstemplate\n=============\n[![4p Logo](https://oupla.bienla.com/mkdgs/4p_logo.png)](http://mkdgs.fr/)\n\nImportant if you use NodeJs, jsdom 3.1.2 is required\n===\n\n```bash\nnpm install -S 'jquery@>=2.1'\nnpm install -S 'jsdom@3.1.2'\n```\n\n(Note that version 3.1.2 of jsdom is required, because as of jsdom version 4.0.0, jsdom no longer works\nwith Node.js.  If you use Io.js rather than Node.js, you can use the latest 4.x release of jsdom.)\nhttps://github.com/UncoolAJ86/node-jquery\nhttps://www.npmjs.com/package/jsdom\n\n\n```\n    /* GET home page. */\n    router.get('/', function(req, res) {\n        var file = 'views/index.html'; // our template file template\n        fs.readFile(file, function (err, content) {\n            if (err) throw err;\n\n            // init template\n            var tpl = $4p_template.template(content.toString()); \n\n            // some data\n            var template_data = { \n                bar: 'hello world',\n                deep: {'foo': {'bar': 'this data is in deep.foo.bar'}},\n                list: ['hop', 'hip', 'hap', 'yip', 'yep']\n            };     \n\n            t = tpl.element.html(tpl.render(template_data)); // render to dom\n\n            // tpl.element is a jquery instance of our template element\n            tpl.element.find('li').css('color', 'red'); // play with it !\n\n            // handle more complex structure and play with dom\n            tpl.renderAfter('table', ''); // render <table>\n            for (i = 1; i <= 11; i++) {\n                tpl.renderAfter('table-line', {cell: [i, i * i]});  // push rendered data in table                \n            }\n\n            var rendered = t.html(); // get html\n            res.send(t.html()); // send output     \n        });\n    };\n```\n\ntest it:\nhttp://jsfiddle.net/mkdgs/FvBnX/\n\ni've made this template engine, with some idea similar to handlebar, but all presentational template logic is in javascript \n(we have don't need to learn a new template language again) and it's easy to mix html and javascript, like php with html.\n\nyou can reuse your template and define repetitive subpart of it.\n\nin template all data is mapped to a $4p.templateData object and has three method is(), iterate(), v()\n\n**$4p.templateData object**\ncan contain value mixed value scalar, array, or object \n\n**is('with','data','path')**\nis used to traverse data tree, this return a $4p.templateData. \nthat's return the data object corresponding to the data path.\nif the data path not exist he return a $4p.templateData with null value,\nso if there no value your code is not breaking and you have not to worry about he data was or was not defined. \n\n**iterate()** \nis used to make a loop throught $4p.templateData object if it's contain object or array value   \n\n**v()**\nreturn the data value passed in template contained in this object\n\ngive me a feedback  ;)\n\n\n\n\nThe templating part is inspired, like many other, from our Guru:\nhttp://ejohn.org/blog/javascript-micro-templating/","maintainers":[{"name":"mkdgs","email":"mickael.desgranges@gmail.com"}],"time":{"modified":"2022-06-12T14:07:51.680Z","created":"2015-03-06T10:18:49.650Z","0.3.0":"2015-03-06T10:18:49.650Z","0.3.1":"2015-03-06T10:24:01.769Z","0.3.2":"2015-03-06T10:40:12.218Z","0.4.0":"2015-03-09T17:17:11.457Z","0.4.1":"2015-03-09T17:22:32.354Z"},"keywords":["template"],"repository":{"type":"git","url":"https://github.com/mkdgs/4p_jstemplate.git"},"author":{"name":"mkdgs","email":"mickael.desgranges@gmail.com","url":"http://mkdgs.fr"},"bugs":{"url":"https://github.com/mkdgs/4p_jstemplate/issues"},"license":"Cecill-B (french BSD-like)","readmeFilename":"README.md"}