Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get {{>partials} working with Consolidate.js & Mustache?
    primarykey
    data
    text
    <p>I cannot get mustache reading partials added like so {{>my_partial}} when using it with consolidate.js. I start my express application with something like:</p> <p>file index.js:</p> <pre><code>var express = require('express'), cons = require('consolidate'); app.configure(function(){ app.set( 'models', BACKEND + '/models' ); // Set the models directory app.set( 'views', BACKEND + '/views' ); // Set the views directory app.set( 'controllers', BACKEND + '/controllers' ); // Set the controllers dir app.set( 'view engine', 'html' ); // Set Mustache as the templating engine app.engine( 'html', cons.mustache ); app.engine( 'mustache', cons.mustache ); app.use( app.router ); // Set the router app.use( '/public', express.static( BASEPATH + '/frontend/public' ) ); // set frontend/public to /public for users app.use( '/js', express.static( BASEPATH + '/frontend/js' ) ); app.use( '/out', express.static( BASEPATH + '/out' ) ); // documentation path // Set client side libraries here (Make them available to the public based on settings.json) for(setting in SETTINGS.public) { app.use( SETTINGS.public[setting], express.static(BASEPATH + SETTINGS.public[setting]) ); } }); </code></pre> <p>Then, somewhere in the controller, I use the render like so:</p> <pre><code>function Blog(app, request, response){ var fs = require('fs'), Blog = require( app.get('models') + '/blog' ), model = new Blog(), scripts = fs.readFileSync( VIEWS + '/m_scripts.mustache').toString() ; model.List(function(data){ response.render('layout', { title : 'My Blog', body : 'Hello Mustache World', list : data.rows, cache : false, partials : { m_scripts : partialStr } } ); }); }; exports.list = Blog; </code></pre> <p>The m_scripts.mustache has:</p> <pre><code>&lt;script data-src="ergierjgoejoij"&gt;&lt;/script&gt; </code></pre> <p>The layout template renders just fine, and the params pass through just fine too, the partial m_scripts gets passed with the text passed by readFileSync().toString() just fine BUT the HTML stuff gets encoded and rendered useless. </p> <p>My question is, is there a way I can just put in the layout.mustache {{>m_scripts}} and mustache understands to load the m_scripts.mustache automatically without the need to pass it to the render(). If not, what am I missing?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload