{"id":37012314,"url":"https://github.com/thoom/phandlebars","last_synced_at":"2026-01-14T01:04:22.191Z","repository":{"id":4928359,"uuid":"6084970","full_name":"thoom/phandlebars","owner":"thoom","description":"Handlebars.js based templating engine for the Silex framework","archived":false,"fork":false,"pushed_at":"2013-02-02T05:43:20.000Z","size":184,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-07-26T15:43:30.618Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thoom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-10-05T02:39:34.000Z","updated_at":"2014-03-01T15:08:49.000Z","dependencies_parsed_at":"2022-09-10T16:51:51.673Z","dependency_job_id":null,"html_url":"https://github.com/thoom/phandlebars","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/thoom/phandlebars","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoom%2Fphandlebars","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoom%2Fphandlebars/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoom%2Fphandlebars/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoom%2Fphandlebars/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thoom","download_url":"https://codeload.github.com/thoom/phandlebars/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thoom%2Fphandlebars/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28407640,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T00:40:43.272Z","status":"ssl_error","status_checked_at":"2026-01-14T00:40:42.636Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-14T01:04:21.423Z","updated_at":"2026-01-14T01:04:22.166Z","avatar_url":"https://github.com/thoom.png","language":"JavaScript","readme":"Thoom Phandlebars\n=================\n\nSummary\n-------\n\nPhandlebars allows you to use Handlebars templates in your Silex applications. Rather than reimplementing the Handlebars\nlibrary in PHP, this provider uses server-side Javascript (primarily with node.js) to both compile the Handlebars templates\nyou've created (making the generated JS file also available for your client-side handling) and process templates on the server.\n\nInstallation\n------------\n\nThere are two parts to the installation: the PHP hooks into your Silex application and the required server-side applications.\n\n### Silex Application\n\nThere are these options currently:\n\n  1. __debug__: If debug is true, then the compiled file will be overwritten with each request. If false, it will only build the compiled file if it doesn't exist.\n  1. __library__: By default, the compiled JS file will use the Handlebars runtime library. If you need to use the full library instead\n                  (for instance, if you dynamically compile on the client side), then pass in `HandlebarsServiceProvider::LIBRARY_FULL`.\n  1. __minify__: If true, the script will attempt to minify the file using the `runtime.minify` command.\n  1. __path.compiled.client__: This is the full file path of where you want the compiled client-only Javascript file to reside. The location should be writable by your web user.\n  1. __path.compiled.server__: This is the full file path of where you want the server compiled Javascript file to reside.\n  1. __path.templates.client__: The directory where all of the client-only Handlebars templates are stored. Note that all of your templates should end with _.handlebars_.\n  1. __path.templates.server__: The directory where all of the server-only Handlebars templates are stored. Note that all of your templates should end with _.handlebars_.\n  1. __runtime.minify__: If not set, the script will attempt to minify the client file using `uglifyjs` command.\n  1. __runtime.node__: If not set, the script will attempt to run node from using `node` command.\n\nAs an example:\n\n    $app-\u003eregister(new Thoom\\Provider\\HandlebarsServiceProvider(), array(\n        'handlebars.options' =\u003e array(\n            'debug' =\u003e $app['debug'],\n            'minify' =\u003e true,\n            'path.compiled.client' =\u003e $app['cache_dir'] . '/js/handlebars-compiled.js',\n            'path.compiled.server' =\u003e $app['cache_dir'] . '/compiled.js',\n            'path.templates.client' =\u003e __DIR__ . '/templates/client',\n            'path.templates.server' =\u003e __DIR__ . '/templates/server',\n        )\n    ));\n\n### Server\n\nThe provider needs a few server cli applications installed in order to render and compile templates.\n\n#### Node.js\n\nEasy to install using the package manager of your choice. For instance, with Ubuntu:\n\n    $ apt-get install nodejs build-essential\n\nThis assumes that your node executable is installed and accessible from `node`. If you need to use a different command,\nchange the `runtime.node` configuration option.\n\n#### Handlebars.js\n\nYou'll need to install using NPM.\n\n    $ apt-get install npm\n    $ npm install -g handlebars\n\n#### UglifyJS (optional)\n\nIf you want to minify your compiled templates, you'll need to install UglifyJS.\n\n    $ npm install -g uglify-js\n\nIf you prefer another minifier, note that it just needs to accept data from `STDIN` and outputs to `STDOUT`. To change the\nminifier, change the `runtime.minify` configuration option.\n\n\nTo Use\n------\n\n### Silex Application\n\n#### Precompile\n\nYou may wish to precompile the script. This can be accomplished by calling the renderer from your application using the following command:\n\n    $app['handlebars']-\u003eserver();\n\nTo precompile handlebars for client only scripts:\n\n    $app['handlebars']-\u003eclient();\n\n#### Server-side rendering\n\nTo render a server-side template for \"index.handlebars\":\n\n    $app-\u003eget('/', function (Application $app) {\n        return $app['handlebars']-\u003erender('index');\n    })-\u003ebind('homepage');\n\nTo add a global variable (like a user array) to be available to your templates:\n\n    $app['handlebars']-\u003eaddGlobal('user', $userArray);\n\nTo pass data to the template at render time, pass in a array as the second argument:\n\n    $app['handlebars']-\u003erender('index', array('foo' =\u003e 'fez'));\n\nTo return an Http header other than 200, pass in a 3rd argument:\n\n    $app['handlebars']-\u003erender('not-found', array('foo' =\u003e 'fez'), 404);\n\n__Note:__ *Since the Handlebars templates are processed in Javascript using node, you can only pass items that are JSON serializable.*\n\n\n### Handlebars templates\n\nIn addition to the standard [Handlebars.js options](https://handlebarsjs.com), you have a few more options that allow you to extend templates similar to Twig.\n\nTo create a master template ('master.handlebars'), use the {{#block}} tag:\n\n    \u003chtml\u003e\n        \u003chead\u003e\n            \u003ctitle\u003e{{#block \"title\"}}Master Template{{/block}}\u003c/title\u003e\n        \u003c/head\u003e\n        ...\n\n\nIn your child template, you would use the {{#override}} and {{extend}} tags:\n\n    {{#override \"title\"}}Child Template{{/override}}\n\n    {{extend \"master\"}}\n\nThis would print:\n\n    \u003chtml\u003e\n        \u003chead\u003e\n            \u003ctitle\u003eChild Template\u003c/title\u003e\n        \u003c/head\u003e\n        ...\n\nNotice that unlike Twig templates, the extend tag is found at the bottom of the script. This is required because of how Handlebars parses templates.\n\n#### Additional Tags\n\n##### path\n\nThis convenience expression takes all of your Silex named routes and makes them available in your templates.\n\nIf your named route \"login\" has a path of \"/login\", you'd use:\n\n    {{path \"login\" }}\n\nIf your named route \"section\" has a path of \"/section/{section}\", you'd use:\n\n    {{path \"section\" section=\"my-section\" }}\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthoom%2Fphandlebars","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthoom%2Fphandlebars","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthoom%2Fphandlebars/lists"}