How to use the handlebars.registerPartial function in handlebars

To help you get started, we’ve selected a few handlebars 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 material-components / material-components-web / test / screenshot / infra / lib / report-writer.js View on Github external
registerPartials_() {
    const partialFilePaths = this.localStorage_.globFiles(path.join(TEST_DIR_RELATIVE_PATH, 'report/_*.hbs'));
    for (const partialFilePath of partialFilePaths) {
      // TODO(acdvorak): What about hyphen/dash characters?
      const name = path.basename(partialFilePath)
        .replace(/^_/, '') // Remove leading underscore
        .replace(/\.\w+$/, '') // Remove file extension
      ;
      const content = this.localStorage_.readTextFileSync(partialFilePath);
      Handlebars.registerPartial(name, content);
    }
  }
github partageit / vegetables / lib / templates-manager.js View on Github external
files.forEach(function(file) {
			// partial templates, to be included in main templates
			if ((file.indexOf('partial-') === 0) && (path.extname(file) === '.html')) {
				try {
					source = fs.readFileSync(path.join(folder, file), {encoding: 'utf-8'});
					handlebars.registerPartial(
						path.basename(file, path.extname(file)).substr('partial-'.length),
						source);
					} catch (e) {
						logger.error('Partial read error "%s": %s', file, e);
					}

				} else if (file.indexOf('per-') === 0) { // other common templates (site, category, tag)
					var filenameParts = file.split('-');
					filenameParts.shift(); // remove 'per-'
					var type = filenameParts.shift();
					var target = filenameParts.join('-');
					commonTemplates.push({
						type: type,
						target: target,
						filename: path.join(folder, file)
					});
github kumavis / ethereum-simulator / lib / view.js View on Github external
function prepareTemplates() {

    // subviews
    Handlebars.registerPartial('wallets',fs.readFileSync('./templates/wallets.hbs').toString())
    Handlebars.registerPartial('contracts',fs.readFileSync('./templates/contracts.hbs').toString())
    Handlebars.registerPartial('details',fs.readFileSync('./templates/details.hbs').toString())
    Handlebars.registerPartial('controls',fs.readFileSync('./templates/controls.hbs').toString())
    Handlebars.registerPartial('blocks',fs.readFileSync('./templates/blocks.hbs').toString())

    // templates
    var appTemplates = {
      app: Handlebars.compile(fs.readFileSync('./templates/app.hbs').toString()),
      new_transaction: Handlebars.compile(fs.readFileSync('./templates/new_transaction.hbs').toString()),
      new_contract: Handlebars.compile(fs.readFileSync('./templates/new_contract.hbs').toString()),
      new_wallet: Handlebars.compile(fs.readFileSync('./templates/new_wallet.hbs').toString()),
      about: Handlebars.compile(fs.readFileSync('./templates/about.hbs').toString()),
      contract: Handlebars.compile(fs.readFileSync('./templates/contract.hbs').toString()),
      transaction: Handlebars.compile(fs.readFileSync('./templates/transaction.hbs').toString()),
      wallet: Handlebars.compile(fs.readFileSync('./templates/wallet.hbs').toString()),
    }
    return appTemplates
  }
github pattern-lab / patternlab-node / packages / engine-handlebars / lib / engine_handlebars.js View on Github external
registerPartial: function(pattern) {
    // register exact partial name
    Handlebars.registerPartial(pattern.patternPartial, pattern.template);

    Handlebars.registerPartial(pattern.verbosePartial, pattern.template);
  },
github NewsJelly / jelly-chart / demo / demo.js View on Github external
async function generate() {
  try {
    const demo = await readFile(path.resolve(__dirname, 'template/demo.hbs'));
    const demoIndex = await readFile(path.resolve(__dirname, 'template/demo.index.hbs'));
    const sidebar = await readFile(path.resolve(__dirname, 'template/partial.side.hbs'));
    const template = handlebars.compile(demo.toString());    
    handlebars.registerPartial('sidebar', sidebar.toString());
    const group = nest().key(d => d.category).entries(list);
    await writeFile(path.resolve(__dirname, distDir, 'index.html'), handlebars.compile(demoIndex.toString())({group:group}));

    let lastL;
    for (let l of list) {
      let categoryPath = l.category.split(' ').join('-');
      let containers;
      if (l.containers && l.containers > 1) {
        let i = 0;
        while( i< l.containers) {
          containers.push('jelly-container-' + i);
        }
      } else {
        containers = ['jelly-container'];
      }
      const code = await readFile(path.resolve(__dirname, srcDir, categoryPath, l.path, 'index.js'));
github mpetrovich / stylemark / src / handlebars.js View on Github external
_.forEach(partials, (filepath, name) => Handlebars.registerPartial(name, fs.readFileSync(path.resolve(__dirname, filepath), 'utf8')));
github HackGT / registration / server / routes / templates.ts View on Github external
return n.toLocaleString();
});
Handlebars.registerHelper("toLowerCase", (n: number): string => {
	return n.toString().toLowerCase();
});
Handlebars.registerHelper("toJSONString", (stat: StatisticEntry): string => {
	return JSON.stringify(stat);
});
Handlebars.registerHelper("removeSpaces", (input: string): string => {
	return input.replace(/ /g, "-");
});
Handlebars.registerHelper("join", (arr: T[]): string  => {
	return arr.join(", ");
});
for (let name of ["sidebar", "login-methods", "form"]) {
	Handlebars.registerPartial(name, fs.readFileSync(path.resolve(STATIC_ROOT, "partials", `${name}.html`), "utf8"));
}

templateRoutes.route("/dashboard").get((request, response) => response.redirect("/"));
templateRoutes.route("/").get(authenticateWithRedirect, async (request, response) => {
	let user = request.user as IUser;

	let applyBranches: Branches.ApplicationBranch[];

	if (user.applicationBranch) {
		applyBranches = [(await Branches.BranchConfig.loadBranchFromDB(user.applicationBranch))] as Branches.ApplicationBranch[];
	}
	else {
		applyBranches = (await Branches.BranchConfig.loadAllBranches("Application") as Branches.ApplicationBranch[]);
	}

	let confirmBranches: Branches.ConfirmationBranch[] = [];
github TheScienceMuseum / collectionsonline / client / templates.js View on Github external
Handlebars.registerPartial(
  'records/record-details',
  Fs.readFileSync('./templates/partials/records/record-details.html', 'utf8')
);

Handlebars.registerPartial(
  'records/record-related-objects',
  Fs.readFileSync('./templates/partials/records/record-related-objects.html', 'utf8')
);

Handlebars.registerPartial(
  'records/panel-cite',
  Fs.readFileSync('./templates/partials/records/panel-cite.html', 'utf8')
);

Handlebars.registerPartial(
  'records/record-imgpanel__controlbar',
  Fs.readFileSync('./templates/partials/records/record-imgpanel__controlbar.html', 'utf8')
);

Handlebars.registerPartial(
  'records/record-related-documents',
  Fs.readFileSync('./templates/partials/records/record-related-documents.html', 'utf8')
);

Handlebars.registerPartial(
  'records/record-related-documents-primary',
  Fs.readFileSync('./templates/partials/records/record-related-documents-primary.html', 'utf8')
);

Handlebars.registerPartial(
  'records/record-related-articles',
github frctl / fractal / src / components / handlebars.js View on Github external
function loadViews(source) {
        for (let item of source.flatten(true)) {
            Handlebars.registerPartial(item.handle, item.content);
            if (item.alias) {
                Handlebars.registerPartial(item.alias, item.content);
            }
        }
        viewsLoaded = true;
    }