yui-pathogen-encoder
Version:
Enables pathogen encoding in YUI Loader
58 lines (57 loc) • 6.31 kB
JSON
{
"name": "locator-handlebars",
"description": "Handlebars template compiler for locator",
"version": "0.2.3",
"author": {
"name": "Caridy Patino",
"email": "caridy@yahoo-inc.com",
"url": "http://github.com/caridy"
},
"contributors": [],
"dependencies": {
"yui": "3.x"
},
"main": "index",
"keywords": [
"framework",
"yui",
"mojito",
"modown",
"handlebars",
"templates"
],
"directories": {
"lib": "./lib",
"yui-modules": "./yui-modules"
},
"engines": {
"node": ">=0.8.x",
"npm": ">=1.2.10"
},
"homepage": "https://github.com/yahoo/locator-handlebars",
"devDependencies": {
"chai": "*",
"istanbul": "*",
"jshint": "~1.1.0",
"yui-lint": "~0.1.3",
"mocha": "*",
"mockery": "1.4.x",
"xunit-file": "*"
},
"scripts": {
"lint": "node node_modules/.bin/jshint --config ./node_modules/yui-lint/jshint.json ./lib/*.js",
"test": "node node_modules/.bin/_mocha tests/lib/*.js --reporter spec"
},
"repository": {
"type": "git",
"url": "https://github.com/yahoo/locator-handlebars.git"
},
"bugs": {
"url": "https://github.com/yahoo/locator-handlebars/issues"
},
"license": "BSD",
"readme": "locator-handlebars\n==================\n\nHandlebars template compiler for locator.\n\n[](https://travis-ci.org/yahoo/locator-handlebars)\n\nThis component is a result of the integration between [YUI][] and [Locator][] component from Yahoo! to compile [Handlebars][]' templates into [YUI][] Modules that could be used on the server thru express and on the client thru [YAF][].\n\nThe beauty of this is that you will NOT need to download the full `handlebars` parser component or the template itself, instead you use YUI Loader to load modules that will provision the handlebars templates in a form of javascript functions ready to be execute to produce a html fragment.\n\n[Handlebars]: http://handlebarsjs.com/\n[Locator]: https://github.com/yahoo/locator\n[YUI]: https://github.com/yui/yui3\n[YAF]: http://yuilibrary.com/yui/docs/app/\n\n\nInstallation\n------------\n\nInstall using npm:\n\n```shell\n$ npm install locator-handlebars\n```\n\nBy installing the module in your express application folder, you should be able to use it thru [Locator][].\n\n\nUsage\n-----\n\n### Integration with `locator` on the server side\n\nNormally, you will plug the locator plugin exposed by `locator-handlebars` into the locator instance, and locator will be able to analyze every file in your express app, and it will compile any `*.hb`, `*.hbs` or `*.handlebars` into a YUI module that can be used thru `express-yui` for example. The example below describes how to use the yui plugin with locator:\n\n```\nvar Locator = require('locator'),\n LocatorHandlebars = require('locator-handlebars'),\n loc = new Locator();\n\n// using locator-handlebars yui plugin\nloc.plug(LocatorHandlebars.yui());\n\n// walking the filesystem for an express app\nloc.parseBundle(__dirname, {});\n```\n\n#### Options\n\nAn options configuration object may be passed to the locator-handlebars plugin creation function `LocatorHandlebars.yui(options)`.\n\nProperties that may be used include:\n- `extensions` - array of string filename extensions to use to identify Handlebars template files. The default is `['hb', 'handlebars', 'hbs']`.\n- `handlebars` - instance of handlebars to use server-side. Default is `require('yui/handlebars').Handlebars`.\n\n\n### Server side with `express` and `express-yui`\n\nYou can try a working example here:\n\nhttps://github.com/yahoo/locator-handlebars/tree/master/example\n\n### Client side with `yui`\n\nOn the client side, any [Handlebars][] template will be accessible as well thru `yui` as a regular yui module. Here is an example:\n\n```\napp.yui.use('<package-name>-templates-bar', function (Y) {\n\n var html = Y.Template._cache['<package-name>/bar']({\n tagline: 'testing with some data for template bar'\n });\n\n});\n```\n\nIn the example above, the `<package-name>` is the package name specified in the `package.json` for the npm package that contains the template, which is usually the express application. `bar` comes from `bar.handlebars` where the filename is used as the name to register the template under `Y.Template`. By using the yui module name, you will be able to invoke the render action to produce a html fragment.\n\n_note: in the near future, `Y.Template.render()` will be the formal API instead of using the `_cache` object, which is protected._\n\n\nPartials\n--------\n\nThis component will support handlebars partials:\n\n* A partial is just another template.\n\n* If a template uses another template (in a form of partial) it will be added to the dependency tree and will be loaded automatically.\n\n* The name used to register the template under `Y.Template` is based on the filename by default, but could be customized to avoid collisions.\n\nIf you want to use a different template name, you can write your own parser:\n\n```\n// using locator-handlebars yui plugin\nloc.plug(LocatorHandlebars.yui({\n nameParser: function (source_path) {\n var libpath = require('path'),\n name = libpath.basename(source_path, libpath.extname(source_path));\n if (source_path.indexOf('partials') > 0) {\n name += '-partial';\n }\n return name;\n }\n}));\n```\n\nIn the example above, when trying to parse `/path/to/foo.hbs` it will return `foo`, but when trying to `/path/to/partials/bar.hbs` it will return `foo-partial`, that will avoid collisions while giving you full control over the name resolution for the compiled templates.\n\nTODO\n----\n\n* Add `helpers` rehydration.\n\n\nLicense\n-------\n\nThis software is free to use under the Yahoo! Inc. BSD license.\nSee the [LICENSE file][] for license text and copyright information.\n\n[LICENSE file]: https://github.com/yahoo/locator-handlebars/blob/master/LICENSE.txt\n\n\nContribute\n----------\n\nSee the [CONTRIBUTE file][] for info.\n\n[CONTRIBUTE file]: https://github.com/yahoo/locator-handlebars/blob/master/CONTRIBUTE.md\n",
"readmeFilename": "README.md",
"_id": "locator-handlebars@0.2.3",
"_from": "locator-handlebars@*"
}