How to use the mustache.compile function in mustache

To help you get started, we’ve selected a few mustache examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github requirejs / element / tests / dynamicView / www / lib / must.js View on Github external
req(deps, function () {

          var mustacheFn,
              // Replace any hrefid/srcid with a {{toUrl:x}} value
              idParsed = parseIds(text, id);

          if (config.isBuild) {
            buildMap[id] = {
              deps: deps,
              idParsed: idParsed
            };
          } else {
            mustacheFn = mustache.compile(idParsed.text);
          }

          var templateFn = must.makeTemplateFn(req);
          templateFn.idParsed = idParsed;
          templateFn.fn = mustacheFn;

          onload({
            template: templateFn
          });
        });
      }, onload.error);
github remy / 5minutefork / index.js View on Github external
'use strict';
var connect = require('connect'),
    fs = require('fs'),
    remove = require('remove'),
    fmf = require('./lib/fmf'), // FiveMinFork - fmf.js
    crypto = require('crypto'),
    request = require('request'),
    http = require('http'),
    mustache = require('mustache'),
    credentials = require('./lib/credentials'),
    forks = {},
    template = mustache.compile(fs.readFileSync(__dirname + '/public/forking.html', 'utf8')),
    error = fs.readFileSync(__dirname + '/public/error.html', 'utf8'),
    timeout = 5 * 60 * 1000,
    debug = process.env.NODE_DEBUG || false;

if (debug) {
  console.log('>>> in debug mode');
}

function createRoute(dir) {
  return connect()
    .use(connect.static(dir))
    .use(connect.directory(dir))
    .use(function (req, res) {
      // if we hit this point, then we have a 404
      res.writeHead(404, { 'content-type': 'text/html' });
      res.end(error);
github concord-consortium / lab / src / lab / common / controllers / share-dialog.js View on Github external
define(function (require) {

  var labConfig      = require('lab.config'),
      mustache       = require('mustache'),
      inherit        = require('common/inherit'),
      BasicDialog    = require('common/controllers/basic-dialog'),
      getCopyright   = require('common/controllers/copyright'),
      shareDialogTpl = require('text!common/controllers/share-dialog.tpl'),

      location = document.location,

      // A tiny template, so define it inline and compile immediately.
      iframeTpl = mustache.compile('');

  /**
   * Share Dialog. Inherits from Basic Dialog.
   *
   * @constructor
   */
  function ShareDialog(parentSelector, interactiveContainerSelector, i18n, interactive) {
    var hash           = location.hash,
        origin         = location.href.match(/(.*?\/\/.*?)\//)[1],
        embeddablePath = location.pathname;

    BasicDialog.call(this, {dialogClass: "share-dialog", appendTo: parentSelector}, i18n);

    /** @private */
github concord-consortium / lab / lab-amd / common / controllers / share-dialog.js View on Github external
define(function (require) {

  var labConfig      = require('lab.config'),
      mustache       = require('mustache'),
      inherit        = require('common/inherit'),
      BasicDialog    = require('common/controllers/basic-dialog'),
      shareDialogTpl = require('text!common/controllers/share-dialog.tpl'),
      copyrightTpl   = require('text!common/controllers/copyright.tpl'),

      location = document.location,

      // A tiny template, so define it inline and compile immediately.
      iframeTpl = mustache.compile('');

  /**
   * Share Dialog. Inherits from Basic Dialog.
   *
   * @constructor
   * @param {Object} interactive Interactive JSON definition.
   * @param {InteractivesController} interactivesController
   */
  function ShareDialog() {
    var hash           = location.hash,
        origin         = location.href.match(/(.*?\/\/.*?)\//)[1],
        embeddablePath = location.pathname.replace(/\/[^\/]+$/, "/embeddable.html");

    BasicDialog.call(this, {dialogClass: "share-dialog"});
github joeferner / wxNode / render-templates.js View on Github external
fs.readFile(path.join("./src-templates", file.templateFileName), 'utf8', function (err, data) {
    if (err) { throw err; }

    var output = Mustache.compile(data, {
      space: true
    })(ctx, null);
    var outputFilename = path.join("./src-generated", ctx.outputFilename);
    var oldContentsCrc = 0;
    if (path.existsSync(outputFilename)) {
      var oldContents = fs.readFileSync(outputFilename, 'utf8');
      oldContentsCrc = crc32(oldContents);
    }
    var newContentsCrc = crc32(output);
    if (oldContentsCrc != newContentsCrc) {
      fs.writeFile(outputFilename, output, callback);
    } else {
      console.log(yellow("skipping " + ctx.outputFilename + " crc match"));
      callback();
    }
  });
github couchbaselabs / TodoLite-PhoneGap / js / index.js View on Github external
$('script[type="text/mustache"]').each(function() {
        var id = this.id.split('-')
        id.pop()
        t[id.join('-')] = mustache.compile(this.innerHTML.replace(/^\s+|\s+$/g,''))
    });
github kof / kiipost / app / src / modules / stream / views / Stream.js View on Github external
var $ = require('jquery'),
    Backbone = require('backbone'),
    mustache = require('mustache'),
    inherits = require('inherits'),
    _ = require('underscore'),
    IScroll = require('iscroll'),
    ImagesLoder = require('images-loader/index')

var conf = require('conf'),
    app = require('app'),
    log = require('log'),
    dataset = require('dataset/index'),
    elementsMap = require('jquery.elementsMap')

var streamTpl = mustache.compile(require('stream/client/templates/stream.html'))

/**
 * Stream constructor.
 *
 * @param {Object} options overrides Stream.defaults
 * @api public
 */
function Stream(options) {
    this.name = 'stream'
    this.options = _.extend({}, Stream.defaults, options)
    this.events = {
        'beforehide.ipanel': '_onBeforeHide',
        'show.ipanel': '_onShow',
        'tap .js-tag': '_onAddTag',
        'tap .js-list-item': '_onItemSelect',
        'mouseover .js-list-item': '_onItemHover',