{"id":19494802,"url":"https://github.com/ceejbot/beam","last_synced_at":"2026-06-07T21:31:38.126Z","repository":{"id":6942303,"uuid":"8193951","full_name":"ceejbot/beam","owner":"ceejbot","description":"browser-side mote.js templating convenience library","archived":false,"fork":false,"pushed_at":"2013-02-14T04:56:26.000Z","size":104,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-10T21:27:35.033Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ceejbot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-02-14T04:55:58.000Z","updated_at":"2013-12-07T04:56:50.000Z","dependencies_parsed_at":"2022-09-15T16:52:27.527Z","dependency_job_id":null,"html_url":"https://github.com/ceejbot/beam","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ceejbot/beam","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Fbeam","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Fbeam/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Fbeam/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Fbeam/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ceejbot","download_url":"https://codeload.github.com/ceejbot/beam/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Fbeam/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285138471,"owners_count":27121052,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-18T02:00:05.759Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":"2024-11-10T21:33:22.893Z","updated_at":"2025-11-18T21:03:05.521Z","avatar_url":"https://github.com/ceejbot.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Beam\n\nBeam is [ICanHaz](http://icanhazjs.com/) rewritten for [mote.js](http://satchmorun.github.com/mote/). It reads moustache-style templates from script tags in an html page and compiles them for later use by other script elements in the page. Beam caches the compiled templates instead of the string source. Also, it is more agnostic than ICanHaz about its optional libraries. It will pick up anything claiming that it is __$__ in the global namespace and assume it works like jquery/zepto. This allows you to use Ender instead of jquery by adding some more packages to your ender build:\n\n`ender add bonzo qwery domready`\n\nAlso has a dependency on [lscache](https://github.com/pamelafox/lscache) for template caching in local storage.\n\n## Usage\n\nBeam imitates ICanHaz's API. It creates a function for every template it finds in the DOM marked as type \"text/html\" or \"text/x-icanhaz\". That method has the following signature:\n\n`beam.templatename(data [, raw])`\n\n`data` must contain a valid context for a mote template. Pass \"true\" for `raw` to receive a string in return. Otherwise Beam will wrap up the result as a dom element.\n\nFor example, given the following html:\n\n```html\n\u003cscript type=\"text/html\" id=\"slartibartfast\"\u003e\n\u003cdiv\u003e\u003ci\u003eGreetings,\u003c/i\u003e {{last}} {{first}} {{last}}.\u003c/div\u003e\n\u003c/script\u003e\n```\n\nbeam creates a function named `slartibartfast` that can be called like this:\n\n```javascript\nvar rendered = beam.slartibartfast({ first: 'Arthur', last: 'Dent' });\n$('#display_it_here').append(rendered);\n```\n\nBeam also provides the following functions. Their names are reserved words; you cannot create templates with the same names.\n\n`beam.addTemplate(name, string)`\n\nAdd a template with the given name and source. Compiles the template and caches the result in `beam.templates[name]`. Creates a function to render the template in `beam[name]`.\n\n`beam.clearAll()` \n\nClear the templates and partials cache.\n\n`beam.grabTemplates()` \n\nSearch the DOM for `\u003cscript type=\"text/html\"\u003e` tags to make templates out of, then remove those elements from the DOM. This function is called automatically when the document is ready.\n\n`beam.refresh()`\n\nClear the cache and re-examine the DOM for new templates.\n\n### Rendering templates\n\n`beam.render(tmpl, data, callback)`\n\nRender the given template name with the passed-in data hash, and fire the callback with the rendering as the sole parameter.\n\n`beam.renderInto(templ, data, element)`\n\nRender into the specified css element. Fire and forget.\n\n### Fetching templates from a server\n\nSet `beam.templateURL` to a string with the url for templates.\n\n`beam.fetch(tmpl, callback)`\n\nFetch `beam.templateURL/tmpl` using ajax, compile the result, and cache it in local storage.\n\nBeam will check local storage to see if it has a cached version of the template already. If it does, it will send an if-modified-since header along with the ajax request for the template.\n\n`beam.preload(tmpllist)`\n\nPass a list of template names. Beam will fetch, compile, and cache whatever is returned by a fetch of `beam.templateURL/tmplname`, falling back to any locally cached versions if the server does not have anything newer.\n\n## License\n\nMIT.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceejbot%2Fbeam","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fceejbot%2Fbeam","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceejbot%2Fbeam/lists"}