{ "_args": [ [ "express-hbs@https://registry.npmjs.org/express-hbs/-/express-hbs-0.8.4.tgz", "/home/nemanja/public_html" ] ], "_from": "express-hbs@0.8.4", "_id": "express-hbs@0.8.4", "_inCache": true, "_location": "/express-hbs", "_phantomChildren": { "ini": "1.3.4", "minimatch": "0.2.14", "mkdirp": "0.5.0", "nopt": "3.0.6" }, "_requested": { "name": "express-hbs", "raw": "express-hbs@https://registry.npmjs.org/express-hbs/-/express-hbs-0.8.4.tgz", "rawSpec": "https://registry.npmjs.org/express-hbs/-/express-hbs-0.8.4.tgz", "scope": null, "spec": "https://registry.npmjs.org/express-hbs/-/express-hbs-0.8.4.tgz", "type": "remote" }, "_requiredBy": [ "/" ], "_resolved": "https://registry.npmjs.org/express-hbs/-/express-hbs-0.8.4.tgz", "_shasum": "6edb2356f91fd776e6e517c973183e12ad053340", "_shrinkwrap": null, "_spec": "express-hbs@https://registry.npmjs.org/express-hbs/-/express-hbs-0.8.4.tgz", "_where": "/home/nemanja/public_html", "author": { "email": "mario@barc.com", "name": "Mario Gutierrez" }, "bugs": { "url": "https://github.com/barc/express-hbs/issues" }, "dependencies": { "handlebars": "^3.0.0", "js-beautify": "1.5.4", "readdirp": "~1.3.0" }, "description": "Express 3 handlebars template engine complete with multiple layouts, partials and blocks.", "devDependencies": { "cookie-parser": "~1.3.3", "express": "~4.11.2", "grunt": "~0.4.1", "grunt-mocha-cli": "~1.12.0", "i18n": "~0.4.1", "mocha": "~2.1.0", "rewire": "~2.2.0", "supertest": "~0.15.0" }, "directories": { "example": "example" }, "homepage": "https://github.com/barc/express-hbs#readme", "keywords": [ "express3", "express", "handlebars", "layout", "partials" ], "license": "MIT", "main": "index.js", "name": "express-hbs", "optionalDependencies": {}, "readme": "# express-hbs\n\nExpress handlebars template engine with multiple layouts, blocks and cached partials.\n\nOpen source project from [Barc](http://barc.com), instant real-time forum on any website.\n\n## Usage\n\nTo use with express 4.\n\n var hbs = require('express-hbs');\n\n // Use `.hbs` for extensions and find partials in `views/partials`.\n app.engine('hbs', hbs.express4({\n partialsDir: __dirname + '/views/partials'\n }));\n app.set('view engine', 'hbs');\n app.set('views', __dirname + '/views');\n\nTo use with express 3 is the same as above, except use hbs.express3\n\n app.engine('hbs', hbs.express3({\n partialsDir: __dirname + '/views/partials'\n }));\n\nOptions for `#express3` and `#express4`\n\n hbs.express4({\n partialsDir: \"{String/Array} [Required] Path to partials templates, one or several directories\",\n\n // OPTIONAL settings\n blockHelperName: \"{String} Override 'block' helper name.\",\n contentHelperName: \"{String} Override 'contentFor' helper name.\",\n defaultLayout: \"{String} Absolute path to default layout template\",\n extname: \"{String} Extension for templates, defaults to `.hbs`\",\n handlebars: \"{Module} Use external handlebars instead of express-hbs dependency\",\n i18n: \"{Object} i18n object\",\n layoutsDir: \"{String} Path to layout templates\",\n templateOptions: \"{Object} options to pass to template()\",\n beautify: \"{Boolean} whether to pretty print HTML, see github.com/einars/js-beautify .jsbeautifyrc,\n\n // override the default compile\n onCompile: function(exhbs, source, filename) {\n var options;\n if (filename && filename.indexOf('partials') > -1) {\n options = {preventIndent: true};\n }\n return exhbs.handlebars.compile(source, options);\n }\n });\n\n\nPartials may use any extension, which is better for syntax highlighting.\n\n## Syntax\n\nTo mark where layout should insert page\n\n {{{body}}}\n\nTo declare a block placeholder in layout\n\n {{{block \"pageScripts\"}}}\n\nTo define block content in a page\n\n {{#contentFor \"pageScripts\"}}\n CONTENT HERE\n {{/contentFor}}\n\n## Layouts\n\nThere are three ways to use a layout, listed in precedence order\n\n1. Declarative within a page. Use handlebars comment\n\n {{!< LAYOUT}}\n\n Layout file resolution:\n\n If path starts with '.'\n LAYOUT is relative to template\n Else If `layoutsDir` is set\n LAYOUT is relative to `layoutsDir`\n Else\n LAYOUT from path.resolve(dirname(template), LAYOUT)\n\n2. As an option to render\n\n res.render('veggies', {\n title: 'My favorite veggies',\n veggies: veggies,\n layout: 'layout/veggie'\n });\n\n This option also allows for layout suppression (both the default layout and when specified declaratively in a page) by passing in a falsey Javascript value as the value of the `layout` property:\n\n res.render('veggies', {\n title: 'My favorite veggies',\n veggies: veggies,\n layout: null // render without using a layout template\n });\n\n Layout file resolution:\n\n If path starts with '.'\n layout is relative to template\n Else If `layoutsDir` is set\n layout is relative to `layoutsDir`\n Else\n layout from path.resolve(viewsDir, layout)\n\n3. Lastly, use `defaultLayout` if specified in hbs configuration options.\n\nLayouts can be nested: just include a declarative layout tag within any layout\ntemplate to have its content included in the declared \"parent\" layout. Be\naware that too much nesting can impact performances, and stay away from\ninfinite loops!\n\n## Helpers\n\nSynchronous helpers\n\n hbs.registerHelper('link', function(text, options) {\n var attrs = [];\n for(var prop in options.hash) {\n attrs.push(prop + '=\"' + options.hash[prop] + '\"');\n }\n return new hbs.SafeString(\n \"\" + text + \"\"\n );\n });\n\n # in markup\n {{{link 'barc.com' href='http://barc.com'}}}\n\nAsynchronous helpers\n\n hbs.registerAsyncHelper('readFile', function(filename, cb) {\n fs.readFile(path.join(viewsDir, filename), 'utf8', function(err, content) {\n cb(new hbs.SafeString(content));\n });\n });\n\n # in markup\n {{{readFile 'tos.txt'}}}\n\n\n## i18n support\n\nExpress-hbs supports [i18n](https://github.com/mashpie/i18n-node)\n\n var i18n = require('i18n');\n\n // minimal config\n i18n.configure({\n locales: ['en', 'fr'],\n cookie: 'locale',\n directory: __dirname + \"/locales\"\n });\n\n app.engine('hbs', hbs.express3({\n // ... options from above\n i18n: i18n, // registers __ and __n helpers\n }));\n app.set('view engine', 'hbs');\n app.set('views', viewsDir);\n\n // cookies are needed\n app.use(express.cookieParser());\n\n // init i18n module\n app.use(i18n.init);\n\n\n## Engine Instances\n\nCreate isolated engine instances with their own cache system and handlebars engine.\n\n var hbs = require('express-hbs');\n var instance1 = hbs.create();\n var instance2 = hbs.create();\n\n## Example\n\nin File `app.js`\n```\n// http://expressjs.com/api.html#app.locals\napp.locals({\n 'PROD_MODE': 'production' === app.get('env')\n});\n\n```\n\nFile `views/layout/default.hbs`\n\n```\n\n \n {{title}}\n \n {{{block \"pageStyles\"}}}\n \n \n {{{body}}}\n\n {{> scripts}}\n\n {{#if PROD_MODE}}\n {{{block 'googleAnalyticsScripts'}}}\n {{/if}}\n\n \n\n```\n\n\nFile `views/index.hbs`\n\n```\n{{!< default}}\n\n{{#contentFor 'pageStyles'}}\n\n{{/contentFor}}\n\n

{{title}}

\n

Click me!

\n```\n\nTo run example project\n\n npm install -d\n node example/app.js\n\n\n## Testing\n\nThe test suite requires the `grunt-cli` package:\n\n npm install -g grunt-cli\n npm install -d\n\nOnce everything's installed, just run:\n\n npm test\n\n\n## Credits\n\nInspiration and code from [donpark/hbs](https://github.com/donpark/hbs)\n\nBig thanks to all [CONTRIBUTORS](https://github.com/barc/express-hbs/contributors)\n\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2012-2014 Barc, Inc.\n\nSee file LICENSE for copying permissions.\n\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git+https://github.com/barc/express-hbs.git" }, "scripts": { "test": "grunt" }, "version": "0.8.4" }