示例#1
0
    _init: function(user) {
        this.id = "account-page";
        this.section_id = "accounts";
        this.roles = [];
        this.role_template = $("#role-entry-tmpl").html();
        Mustache.parse(this.role_template);

        this.keys_template = $("#authorized-keys-tmpl").html();
        Mustache.parse(this.keys_template);
        this.authorized_keys = null;

        this.user = user;
    },
示例#2
0
    cacheTemplate: function(template) {
        if(typeof(template) !== 'string'){
            throw new Error('Please provide a valid mustache template.');
        }

        Mustache.parse(template);
    }
示例#3
0
    var processPokerPagesJson = function processPokerPagesJson(response, lang) {
        var data = JSON.parse(response), i, page, html, hpcount = 0;
        mustache.parse(loadTemplate('page')); //should speed up rendering
        for (i = 0; i < data.page.children.length; i++) {

            page = data.page.children[i];
            page.realLink = config.skin.realUrlBase + '#/poker/?page=' + encodeURIComponent(page.slug) + '&lang=' + lang;
            page.htmlLink =  config.skin.pagesUrlBase + getPageLink(page, lang, 'poker-');
            page.canonicalLink = (config.skin.canonicalUrlBase && config.skin.canonicalUrlBase[lang] ? config.skin.canonicalUrlBase[lang] : config.canonicalUrlBase[lang]) + 'pages/' + getPageLink(page, lang, 'poker-');
            page.metaTitle = config.skin.title[lang].poker;
            page.description = config.skin.description[lang].poker;
            page.keywords = config.skin.keywords[lang].poker;
            sitemap.push({loc: config.skin.pagesUrlBase + getPageLink(page, lang, 'poker-'), lastmod: new Date(page.date).toISOString()});
            hpcount++;

            if (data.page.children[i - 1] !== undefined) {
                page.prev = {link: getPageLink(data.page.children[i - 1], lang, 'poker-'), title: data.page.children[i - 1].title };
            }
            if (data.page.children[i + 1] !== undefined) {
                page.next = {link: getPageLink(data.page.children[i + 1], lang, 'poker-'), title: data.page.children[i + 1].title };
            }

            html = mustache.render(loadTemplate('page'), page);

            fs.writeFile(config.rootSavePath + 'pages/' + getPageLink(page, lang, 'poker-'), html, config.writeOptions);

        }
        saveSiteMap(sitemap);
        console.log(hpcount + ' poker pages created for ' + lang);
    };
示例#4
0
function template(name) {
  mustache.parse(templates[name])

  return function templatize(data) {
    return mustache.render(templates[name], data, templates)
  }
}
示例#5
0
    files.forEach(function(file) {
      templates[file] = grunt.file.read(path.join(p, file));

      // Cache template
      Mustache.parse(templates[file]);
      grunt.verbose.write("Compiled template " + path.join(p, file));
    });
  fs.readFile(inFileName, function (error, inFile) {
    if (error) {
      throw error;
    }
    var tokens = mustache.parse(inFile.toString()),
        cachedTemplate = [
          'var mustache = require("mustache");',
          'var writer = new mustache.Writer(),',
          '    tokens = ' + JSON.stringify(tokens) + ';',
          'module.exports = function(view) {',
          '  return writer.renderTokens(tokens, new mustache.Context(view));',
          '}'
        ].join('\n');

    if (outFileName) {

      if (!isAbsolute(outFileName)) {
        outFilename = path.resolve(process.cwd(), outFileName);
      }

      fs.writeFile(outFilename, cachedTemplate, function(error) {
        if(error) {
          throw error;
        }
      });

    } else {
      console.log(cachedTemplate);
    }

  });
        renderPartial: function (partial_name, params) {
            if (!Partials.hasOwnProperty(partial_name)) return '';
            if (typeof params != 'object') params = {};
            var partial = Partials[partial_name];
            Mustache.parse(partial);

            return Mustache.render(partial, params);
        },
示例#8
0
 function getContent(target_url){
   var bouncerTemplate = fs.readFileSync("./bouncer-template.html", "utf8")
   mustache.parse(bouncerTemplate)
   var values = {
     "target_url" : target_url,
   }
   return mustache.render(bouncerTemplate, values)
 }
示例#9
0
 src._read = function () {
   mustache.parse(template); // speeds up mustache templating
   webParts.forEach(function(webPart) {
     var templatedOutput = mustache.render(template, {htmlFilePrefix: webPart.htmlFilePrefix});
     this.push(new gutil.File({ cwd: __dirname, base: path.join(__dirname, './webParts/'), path: path.join(__dirname, './webParts/', webPart.name + '.webpart.xml'), contents: new Buffer(templatedOutput) }))
     this.push(null)
   }, this)
 }
示例#10
0
        node.on("input", function(msg) {

            try {
                /***
                * Allow template contents to be defined externally
                * through inbound msg.template IFF node.template empty
                */
                var template = node.template;
                if (msg.hasOwnProperty("template")) {
                    if (template == "" || template === null) {
                        template = msg.template;
                    }
                }

                if (node.syntax === "mustache") {
                    var is_json = (node.outputFormat === "json");
                    var promises = [];
                    var tokens = extractTokens(mustache.parse(template));
                    var resolvedTokens = {};
                    tokens.forEach(function(name) {
                        var context = parseContext(name);
                        if (context) {
                            var type = context.type;
                            var store = context.store;
                            var field = context.field;
                            var target = node.context()[type];
                            if (target) {
                                var promise = new Promise((resolve, reject) => {
                                    target.get(field, store, (err, val) => {
                                        if (err) {
                                            reject(err);
                                        } else {
                                            resolvedTokens[name] = val;
                                            resolve();
                                        }
                                    });
                                });
                                promises.push(promise);
                                return;
                            }
                        }
                    });

                    Promise.all(promises).then(function() {
                        var value = mustache.render(template, new NodeContext(msg, node.context(), null, is_json, resolvedTokens));
                        output(msg, value);
                    }).catch(function (err) {
                        node.error(err.message,msg);
                    });
                } else {
                    output(msg, template);
                }
            }
            catch(err) {
                node.error(err.message, msg);
            }
        });
示例#11
0
                    compile: function (template) {

                        Mustache.parse(template);

                        return function (context) {

                            return Mustache.render(template, context, partials);
                        };
                    },
示例#12
0
 fs.readFile(file, { encoding: 'utf8' }, function (err, template) {
     if (err) {
         done(err);
     } else {
         mustache.parse(template);
         cache[file] = template;
         next();
     }
 });
示例#13
0
var makeTemplate = (testCase) => {
  var template = fs.readFileSync(program.template, 'utf8');
  mustache.parse(template);
  var objects = {
    reloadAddress: program.serverAddress,
    content: testCase
  };
  return mustache.render(template, objects);
}
示例#14
0
 // template use {{mustache}} syntax to define fields
 async loadTemplate(ref) {
   const raw = await fsPromises.readFile(
     path.join(__dirname, PATH_TEMPLATES, ref.toLowerCase() + SUFFIX),
     'utf8',
   );
   if (raw) {
     this.template = raw;
     mustache.parse(this.template);
   }
 }
示例#15
0
 parseQuery() {
   let parameters = [];
   try {
     const parts = Mustache.parse(this.query.query);
     parameters = uniq(collectParams(parts));
   } catch (e) {
     logger('Failed parsing parameters: ', e);
   }
   return parameters;
 }
示例#16
0
/**
 *
 */
function transformJSXtache(jsxtache) {
  var mustache = '', jsx = '';
  var tokens = tokenize(jsxtache);

  // console.log(tokens);
  var result = crossCompile(mustache, jsx, tokens);
  return {
    mustache: result.mustache,
    jsx: result.jsx
  }
}
示例#17
0
Mustache.prototype.getPartials = function(fileObj){
    var self = this;
    var promises = [];
    var arrParsed = mustache.parse(fileObj.contents.toString('utf-8'));
    arrParsed.forEach(function (item) {
        if (item[0] == '>') {
            promises.push(self.getPartialFile(fileObj.base, item[1]));
        }
    });
    return Promise.all(promises);
};
示例#18
0
 /**
  * @render datepicker view element
  * @param data
  */
 render (data) {
     if (!data) {
         data = this.model.state.view;
     }
     Helper.debug(this, 'render');
     Mustache.parse(Template);
     this.rendered = $(Mustache.render(this.model.options.template, this.getViewModel(data)));
     this.$container.empty().append(this.rendered);
     this.markSelectedDay();
     this.markToday();
     this.afterRender();
 }
示例#19
0
 parseQuery() {
   let parameters = [];
   try {
     const parts = Mustache.parse(this.query.query);
     parameters = uniq(collectParams(parts));
   } catch (e) {
     logger('Failed parsing parameters: ', e);
     // Return current parameters so we don't reset the list
     parameters = map(this.query.options.parameters, i => i.name);
   }
   return parameters;
 }
示例#20
0
/**
* Displays the about page to #main
*
* @return {Void}
*/
function showAbout(){
  // Remove current information and display loading animation
  clearMainContainer();
  startLoadingAnimation();

  const aboutTemplate = require('./templates/about.html')
  mustache.parse(aboutTemplate);
  $('#main').html(
    mustache.render(aboutTemplate, {
      versionNumber: require('electron').remote.app.getVersion(),
    })
  );
  stopLoadingAnimation();
}
示例#21
0
export function init() {
	clear();

	if (!grid) {
		grid = new Isotope(config.GRID_SELECTOR, {
			itemSelector: GRID_ITEM_SELECTOR,
			layoutmode: 'packery',
			resize: false,
			columnWidth: GRID_ITEM_SELECTOR
		});

		itemTemplate = Mustache.parse(template);
	}

	$(window).on('resize', _.debounce(render, 500));

	return grid;
}
示例#22
0
SwaggerResolver.prototype.resolveTemplate = function(obj) {
	var tmplpath, tmpl, args, text;

	tmplpath = obj['$template'];
	tmpl = this.templates[tmplpath];

	if( !tmpl ) {
		tmpl = this.loadFile(tmplpath);
		this.templates[tmplpath] = tmpl;
		Mustache.parse(tmpl.template);
	}

	// Validate arguments?
	args = _.extend({}, TEMPLATE_FUNCS, this.templateArguments, obj['arguments']);
	validateTemplateArgs(tmplpath, tmpl, args);

	// Render the template, and parse
	text = Mustache.render(tmpl.template, args);
	return yaml.safeLoad(text);
};
示例#23
0
文件: app.js 项目: inbn/drumcircle
function updateDrumNumber () {
  var template = $('#template').html();
  var $target = $('#individualDrumSettings');

  numberOfDrums = $('#drumCount').val();
  Mustache.parse(template);
  $target.empty();

  for (var i = 0; i < numberOfDrums; i += 1) {
    // Add options for this drum to page
    $target.append(Mustache.render(template, Object.assign(drumTracks[i], { index: i })));
    // Change value of select element to match that in samples array
    $('#drum' + i + 'Sample').val(drumTracks[i].sample);
  }

  for (var j = 0; j < 8; j += 1) {
    if (j < numberOfDrums) {
      layers[j].show();
    } else {
      layers[j].hide();
    }
  }

  // Create event listeners for each sector count input
  $('.js-drum-sector-count').change(function () {
    var index = $('.js-drum-sector-count').index(this);
    drumTracks[index].divisions = parseInt($(this).val());
    drawDrumLayer(index);
  });

  $('.js-drum-sample').change(function () {
    var index = $('.js-drum-sample').index(this);
    loadSoundFile(this.value, index);
  });

  // Update clockHand radius
  clockHand.outerRadius(innerRadius + (arcWidth * numberOfDrums));
  clockHandLayer.draw();
}
示例#24
0
    var processNewsJson = function (response, lang) {
        var data, i, post, html, path;
        try {
            data = JSON.parse(response);
        } catch (e) {
            console.log(e, response);
        }
        var templateStr = loadTemplate('news');
        mustache.parse(templateStr); //should speed up rendering
        for (i = 0; i < data.posts.length; i++) {
            post = data.posts[i];
            //sitemap data
            sitemap.push({loc: config.skin.newsUrlBase + getNewsLink(post), lastmod: new Date(post.date).toISOString()});

            if (data.posts[i - 1] !== undefined) {
                post.prev = {link: getNewsLink(data.posts[i - 1]), title: data.posts[i - 1].title };
            }
            if (data.posts[i + 1] !== undefined) {
                post.next = {link: getNewsLink(data.posts[i + 1]), title: data.posts[i + 1].title };
            }
            post.realLink = config.skin.realUrlBase + '#/news?lang=' + lang + '&news=' + post.id + '#lnews-' + post.id;
            post.htmlLink = config.skin.newsUrlBase + getNewsLink(post, lang);
            post.canonicalLink = (config.skin.canonicalUrlBase && config.skin.canonicalUrlBase[lang] ? config.skin.canonicalUrlBase[lang] : config.canonicalUrlBase[lang]) + 'news/' + getNewsLink(post);
            post.metaTitle = config.skin.title[lang].news;
            post.description = config.skin.description[lang].news;
            post.keywords = config.skin.keywords[lang].news;
            html = mustache.render(templateStr, post);
            path = config.rootSavePath + 'news/' + getNewsLink(post);
            if (!fs.existsSync(path)) {
                bagpipe.push(fs.writeFile, config.rootSavePath + 'news_delta/' + getNewsLink(post), html, config.writeOptions);
            }
            bagpipe.push(fs.writeFile, path, html, config.writeOptions);
        }
        if (!onlyUpdateNews) {
            saveSiteMap(sitemap);  //will not update sitemap when only checking for news update
        }

        console.log(data.posts.length + ' news created for ' + lang);
    };
 var getFacebookView = function () {
     var facebookTemplate = document.getElementById('socialFeeds-facebook').innerHTML;
     Mustache.parse(facebookTemplate);
     var facebookCompiled = Mustache.render(facebookTemplate, this.facebookData);
     this.facebookContainer.innerHTML = facebookCompiled;
 };
 var getTwitterView = function () {
     var twitterTemplate = document.getElementById('socialFeeds-twitter').innerHTML;
     Mustache.parse(twitterTemplate);
     var twitterCompiled = Mustache.render(twitterTemplate, this.twitterData);
     this.twitterContainer.innerHTML = twitterCompiled;
 };
 var getInstagramView = function () {
     var instagramTemplate = document.getElementById('socialFeeds-instagram').innerHTML;
     Mustache.parse(instagramTemplate);
     var instagramCompiled = Mustache.render(instagramTemplate, this.instagramData);
     this.instagramContainer.innerHTML = instagramCompiled;
 };
'use strict';

// MODULES //

var mustache = require( 'mustache' );
var validate = require( './validate.js' );


// TEMPLATES //

var URL = 'https://npmjs.com/package/{{package}}';
var IMAGE = 'https://img.shields.io/npm/v/{{package}}.{{format}}?style={{style}}';

mustache.parse( URL );
mustache.parse( IMAGE );


// URLS //

/**
* FUNCTION: urls( options )
*	Creates Shields.io badge URLs.
*
* @param {Object} options - function options
* @param {String} options.package - package name
* @param {String} [options.style="flat"] - badge style
* @param {String} [options.format="svg"] - badge format
* @returns {Object}
*/
function urls( options ) {
	var opts;
示例#29
0
文件: Pages.js 项目: 19h47/19h47.fr
			title: response[0].title.rendered,
			content: response[0].content.rendered,
		};

		return post;
	},


	/**
	 * Pages.append
	 */
	append(post) {
		// console.dir(post);
		const template = {
			title: $('#page-title').html(),
			content: $('#page-content').html(),
		};

		Mustache.parse(template.title);
		Mustache.parse(template.content);

		const htmlTitle = Mustache.render(template.title, { title: post.title });
		const htmlContent = Mustache.render(template.content, { content: post.content });

		this.$element.find('.js-title').append(htmlTitle);
		this.$element.find('.js-content').append(htmlContent);
	},
};

export default Pages;
示例#30
0
$(document).ready(function() {

  // Components
  var component = {

    // CSS3
    css3 : {
      name: "CSS3",
      className: "devicons devicons-css3",
      iconName:"devicons-css3"
    },

    // Bootstrap
    bootstrap : {
      name: "Bootstrap",
      className: "devicons devicons-bootstrap",
      iconName:"devicons-bootstrap"
    },

    // HTML5
    html5 : {
      name: "HTML5",
      className: "devicons devicons-html5",
      iconName:"devicons-html5"
    },

    // jQuery
    jquery: {
      name: "jQuery",
      className: "devicons devicons-jquery",
      iconName:"devicons-jquery",
      iconDescription: "A JavaScript library used to provide a View for data rendered as HTML."
    },

    // JavaScript
    javascript: {
      name: "JavaScript",
      className: "devicons devicons-javascript_badge",
      iconName:"devicons-javascript_badge"
    },

    // Mustache.js
    mustache: {
      name: "mustache.js",
      className: "devicons devicons-code",
      iconName:"devicons-code",
      iconDescription: "A logic-less HTML templating system."
    },

    // React
    react: {
      name: "React",
      className: "devicons devicons-react",
      iconName:"devicons-react",
      iconDescription: "A JavaScript library used to provide a View for data rendered as HTML."
    },

    // Sass
    sass: {
      name: "Sass",
      className: "devicons devicons-sass",
      iconName:"devicons-sass",
      iconDescription: "A CSS pre-processor with syntax advancements."
    },

    // Materialize
    materialize: {
      name: "Materialize",
      className: "devicons devicons-materializecss",
      iconName: "devicons-materializecss",
      iconDescription: "A modern responsive front-end framework based on Material Design"
    },

    // D3
    d3: {
      name: "D3.js",
      className: "devicons devicons-code",
      iconName:"devicons-code",
      iconDescription: "A JavaScript library for manipulating documents based on data."
    },

    // Node
    nodejs: {
      name: "Node.js",
      className: "devicons devicons devicons-nodejs",
      iconName: "devicons-nodejs",
      iconDescription: "Node.js is an open-source, cross-platform runtime environment for developing server-side Web applications."
    },

    // Express
    expressjs: {
      name: "Express.js",
      className: "devicons devicons-code",
      iconName: "devicons-code",
      iconDescription: "Express.js is a Node.js web application framework for creating web and network applications."
    },


  }

  // Select the template.
  var template = $("#template-portfolio-project").html();

  // Portfolio Project Data.
  var data = {

    // List of projects.
    projects: [


      {
        image: "../images/portfolio/cover-timestamp-generator.png",
        title: "Timestamp Generator Microservice",
        description: "Simple Node.js/Express.js application to convert between Natural Dates and Unix Epoch Dates",
        popout: {
          id: "portfolio-project-13"
        },
        components: [component.html5, component.css3, component.react, component.nodejs, component.expressjs],
        link: {
          github: "https://github.com/Jon1701/MS-Timestamp",
          demo: "https://ms-timestamp-jon1701.c9users.io"
        }
      },


      {
        image: "../images/portfolio/cover-requestheaderparser.png",
        title: "Request Header Parser Microservice",
        description: "Simple Node.js/Express.js application to parse web browser HTTP request headers",
        popout: {
          id: "portfolio-project-12"
        },
        components: [component.html5, component.css3, component.react, component.nodejs, component.expressjs],
        link: {
          github: "https://github.com/Jon1701/MS-RequestHeaderParser",
          demo: "https://ms-request-header-parser-jon1701.c9users.io"
        }
      },


      {
        image: "../images/portfolio/cover-recipebox.png",
        title: "Recipe Box",
        description: "Simple web application built using React.js and Materialize to store recipes using a web browser's local storage",
        popout: {
          id: "portfolio-project-1"
        },
        components: [component.html5, component.css3, component.javascript, component.react, component.materialize],
        link: {
          github: "https://github.com/Jon1701/RecipeBox",
          demo: "../portfolio/RecipeBox"
        }
      },


      {
        image: "../images/portfolio/cover-dungeoncrawler.png",
        title: "Dungeon Crawler",
        description: "A simple dungeon crawler game",
        popout: {
          id: "portfolio-project-11"
        },
        components: [component.html5, component.css3, component.javascript, component.react],
        link: {
          github: "https://github.com/Jon1701/DungeonCrawler",
          demo: "../portfolio/DungeonCrawler"
        }
      },


      {
        image: "../images/portfolio/cover-gameoflife.png",
        title: "The Game of Life",
        description: "A simulation of Conway's Game of Life, built with React.js",
        popout: {
          id: "portfolio-project-10"
        },
        components: [component.html5, component.css3, component.javascript, component.react],
        link: {
          github: "https://github.com/Jon1701/GameOfLife",
          demo: "../portfolio/GameOfLife"
        }
      },


      {
        image: "../images/portfolio/cover-d3-projects.png",
        title: "FreeCodeCamp D3 Charts",
        description: "A collection of charts made in D3",
        popout: {
          id: "portfolio-project-9"
        },
        components: [component.html5, component.css3, component.javascript, component.d3],
        link: {
          github: "https://github.com/Jon1701/FCC-D3-Projects",
          demo: "../portfolio/D3Projects"
        }
      },


      {
        image: "../images/portfolio/cover-twitch-viewer.png",
        title: "TwitchViewer",
        description: "See what some of my favourite Twitch streamers are playing",
        popout: {
          id: "portfolio-project-4"
        },
        components: [component.html5, component.css3, component.javascript, component.jquery, component.react],
        link: {
          github: "https://github.com/Jon1701/TwitchViewer",
          demo: "../portfolio/TwitchViewer"
        }
      },


      {
        image: "../images/portfolio/cover-markdown-previewer.png",
        title: "Markdown Previewer",
        description: "Converts markdown into HTML markup",
        popout: {
          id: "portfolio-project-8"
        },
        components: [component.html5, component.css3, component.javascript, component.react],
        link: {
          github: "https://github.com/Jon1701/MarkdownPreviewer",
          demo: "../portfolio/MarkdownPreviewer"
        }
      },


      {
        image: "../images/portfolio/cover-simongame.png",
        title: "Simon Game",
        description: "A classic, rebuilt for modern times, and in 4K. (Batteries not included)",
        popout: {
          id: "portfolio-project-3"
        },
        components: [component.html5, component.css3, component.javascript, component.jquery],
        link: {
          github: "https://github.com/Jon1701/SimonGame",
          demo: "../portfolio/SimonGame"
        }
      },


      {
        image: "../images/portfolio/cover-wikiviewer.png",
        title: "Wiki Viewer",
        description: "Search for Wikipedia using Wikipedia",
        popout: {
          id: "portfolio-project-5"
        },
        components: [component.html5, component.css3, component.javascript, component.jquery, component.mustache],
        link: {
          github: "https://github.com/Jon1701/WikiViewer",
          demo: "../portfolio/WikiViewer"
        }
      },


      {
        image: "../images/portfolio/cover-pumpkindoro-timer.png",
        title: "Pumpkindoro Timer",
        description: "A variation of the world famous Pomodoro Timer, now made with real pumpkins.",
        popout: {
          id: "portfolio-project-2"
        },
        components: [component.html5, component.css3, component.javascript, component.jquery],
        link: {
          github: "https://github.com/Jon1701/PumpkindoroTimer",
          demo: "../portfolio/PumpkindoroTimer"
        }
      },


      {
        image: "../images/portfolio/cover-quote-generator.png",
        title: "Life is Strange Quote Generator",
        description: "Relive the horror here with quotes from the game",
        popout: {
          id: "portfolio-project-7"
        },
        components: [component.html5, component.css3, component.javascript, component.jquery],
        link: {
          github: "https://github.com/Jon1701/LifeIsStrangeQuoteGenerator",
          demo: "../portfolio/LifeIsStrangeQuoteGenerator"
        }
      },


    ]// End list.
  } // End data

  // Parse template.
  Mustache.parse(template);

  // Render template.
  var rendered = Mustache.render(template, data);

  // Attach template.
  $("#portfolio-target").html(rendered);

});