Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.gitmodules Basic mustache test and complex test working
README.markdown CanJS compatibility
handlebars.js Updated Handlebars to 1.0.beta.5 and fixed a unit test that was missi…
mustache.js combine passed in helpers and partials with globals
qunit.html Basic mustache test and complex test working



mustache-javascriptmvc brings the power of the Mustache templating language and its superset handlebars.js to CanJS and JavaScriptMVC.

Checkout the official Handlebars docs site at for syntax.


NOTE: steal is required to use this plugin with CanJS.

./steal/js steal/getjs mustache

Alternatively, you can grab the code from the Github repository:

git clone git:// mustache

Configure it to load for all .mustache files in your stealconfig.js:

    map: {
        "*": {
            'jquery/jquery.js' : "jquery",
            "can/util/util.js": "can/util/jquery/jquery.js"
    paths: {
        "jquery": "can/util/jquery/jquery.1.8.1.js"
    ext: {
        js: "js",
        css: "css",
        less: "steal/less/less.js",
        coffee: "steal/coffee/coffee.js",
        mustache: "mustache/mustache.js"

Create some .mustache files and use them normally:

steal("//views/template.mustache",function(template) {
    $("#elem").html(template({ variable: "Value" }))

Using "hookupModel" and "hookupView":

<script type="text/mustache" id="subView">
    <div {{{hookupModel}}}></div>

<script type="text/mustache" id="mainView">
    {{#each this}}
        {{{hookupView "subView" this}}}

Passing extra helpers to a view:

steal("//views/template.mustache",function(template) {
    $("#elem").html(template({ variable: "Value" },{
        helpers: { plus: function(x,y) { return x + y; } }
<p>{{x}} + {{y}} = {{plus x y}}</p>

Using partials:

steal("//views/template.mustache","//views/subView.mustache",function(template,subView) {
    $("#elem").html(template({ variable: "Value" },{
        partials: { subView: subView }


<div {{{hookupModel}}}></div>


{{#each this}}
    {{{> subView}}}
Something went wrong with that request. Please try again.