How to use the mustache.parse 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 cockpit-project / cockpit / pkg / storaged / overview.js View on Github external
function init_overview(client, jobs) {
        var read_series, write_series;

        $('#vgroups').toggle(client.features.lvm2);
        $('#iscsi-sessions').toggle(client.features.iscsi);

        var mdraids_tmpl = $("#mdraids-tmpl").html();
        mustache.parse(mdraids_tmpl);

        function render_mdraids() {
            function cmp_mdraid(path_a, path_b) {
                // TODO - ignore host part
                return client.mdraids[path_a].Name.localeCompare(client.mdraids[path_b].Name);
            }

            function make_mdraid(path) {
                var mdraid = client.mdraids[path];

                return {
                    path: path,
                    UUID: mdraid.UUID,
                    Size: utils.fmt_size(mdraid.Size),
                    Name: utils.mdraid_name(mdraid)
                };
github cogolabs / cyto / src / args / parseArgsFromDependencies / parseArgsFromDependencies.js View on Github external
.reduce((accum, dep) => {
      const contents = loadDependency(dep);
      const tokens = mustache.parse(contents)
        .filter((x) => x[0] !== 'text')
        .map((x) => ({ id: x[1] }))
        .filter((x) => x.id !== 'author' && x.id !== 'id'); // Provided by cyto

      return [
        ...accum.filter((x) => !tokens.includes(x)),
        ...uniqBy(tokens, 'id'),
      ];
    }, []);
}
github dcloudio / uni-app / packages / uni-migration / lib / mp-weixin / transform / template-transformer / transform / traverse.js View on Github external
function parseMustache(expr, identifier = false) {
  if (!expr) {
    return ''
  }
  const tokens = parse(expr)
  const isIdentifier = tokens.length === 1
  return tokens.map(token => {
    if (token[0] === 'text') {
      if (identifier) {
        return token[1]
      }
      return `'${token[1]}'`
    } else if (token[0] === '!') { // {{ !loading }}
      return `(!${token[1]})`
    } else if (token[0] === 'name') {
      if (isIdentifier) {
        return token[1]
      }
      return `(${token[1]})`
    }
  }).join('+')
github odrick / free-tex-packer / src / client / ui / EditCustomExporter.jsx View on Github external
save() {
        let exporter = getExporterByType("custom");
        
        let content = ReactDOM.findDOMNode(this.refs.content).value;
        let allowTrim = ReactDOM.findDOMNode(this.refs.allowTrim).checked;
        let allowRotation = ReactDOM.findDOMNode(this.refs.allowRotation).checked;
        let fileExt = ReactDOM.findDOMNode(this.refs.fileExt).value;
        
        try {
            mustache.parse(content);

            exporter.content = content;
            exporter.allowTrim = allowTrim;
            exporter.allowRotation = allowRotation;
            exporter.fileExt = fileExt;
            
            Storage.save(STORAGE_CUSTOM_EXPORTER_KEY, exporter);
            
            Observer.emit(GLOBAL_EVENT.HIDE_EDIT_CUSTOM_EXPORTER);
        }
        catch(e) {
            Observer.emit(GLOBAL_EVENT.SHOW_MESSAGE, I18.f("EXPORTER_ERROR", e.message));
        }
    }
github cockpit-project / cockpit / pkg / storaged / overview.js View on Github external
};
            }

            var m = Object.keys(client.mdraids).sort(cmp_mdraid).map(make_mdraid);
            $('#mdraids').amend(mustache.render(mdraids_tmpl,
                                                { MDRaids: m,
                                                  HasMDRaids: m.length > 0
                                                }));
            permissions.update();
            jobs.update('#mdraids');
        }

        $(client).on('changed', render_mdraids);

        var vgroups_tmpl = $("#vgroups-tmpl").html();
        mustache.parse(vgroups_tmpl);

        function render_vgroups() {
            function cmp_vgroup(path_a, path_b) {
                return client.vgroups[path_a].Name.localeCompare(client.vgroups[path_b].Name);
            }

            function make_vgroup(path) {
                var vgroup = client.vgroups[path];

                return {
                    path: path,
                    Size: utils.fmt_size(vgroup.Size),
                    Name: vgroup.Name
                };
            }
github hapijs / vision / examples / mustache / partials.js View on Github external
compile: function (template) {

                    Mustache.parse(template);

                    return function (context) {

                        return Mustache.render(template, context, partials);
                    };
                },
github PacktPublishing / Node.js_Design_Patterns_Second_Edition_Code / Chapter08 / 04_webpack_es2015 / src / sayHello.js View on Github external
"use strict";

const mustache = require('mustache');
const template = '<h1>Hello <i>{{name}}</i></h1>';
mustache.parse(template);
module.exports.sayHello = toWhom =&gt; {
  return mustache.render(template, {name: toWhom});
};
github easynode / easynode / src / easynode / framework / mvc / MustacheTemplateViewRenderer.js View on Github external
render(actionResult, template) {
      mustache.parse(template);
      var o = actionResult.toJSON();
      this._injectHelperFunctions(o);
      return mustache.render(template, o.result);
    }
github node-red / node-red / red / api / editor / ui.js View on Github external
init: function(_runtimeAPI) {
        runtimeAPI = _runtimeAPI;
        editorTemplate = fs.readFileSync(path.join(templateDir,"index.mst"),"utf8");
        Mustache.parse(editorTemplate);
    },
github emojicode / emojicode.github.io / lib / compiler.js View on Github external
fs.readdirSync(this.compiler.srcPath('templates')).forEach((filename) => {
      const name = path.basename(filename, '.mustache');
      this.templates[name] = fs.readFileSync(this.compiler.srcPath('templates', filename), 'utf8');
      Mustache.parse(this.templates[name]);
    });
  }