How to use the registerPartial function from handlebars

Find comprehensive JavaScript handlebars.registerPartial code examples handpicked from public code repositorys.

64
65
66
67
68
69
70
71
72
  }
};

var registerPartial = function(filename, content) {
  try {
    handlebars.registerPartial(filename, content);
  } catch (ex) {}
};

fork icon21
star icon0
watch icon1

+ 3 other calls in file

343
344
345
346
347
348
349
350
351
352
353
        }


        for(const partialPath of partialFiles){
            const partialName = path.parse(partialPath).name;
            const partialCompiled = compile(fs.readFileSync(partialPath, 'utf-8'));
            handlebars.registerPartial(partialName, render(partialCompiled, partialData));
        }
    }
};

fork icon7
star icon48
watch icon3

137
138
139
140
141
142
143
144
145
146
/*
 * These configuration properties can't be injected directly into the template because
 * they themselves are templates. Instead, we register them as partials, which allows
 * them to be evaluated as part of the templates they're used in.
 */
Handlebars.registerPartial("commitUrl", config.commitUrlFormat);
Handlebars.registerPartial("compareUrl", config.compareUrlFormat);
Handlebars.registerPartial("issueUrl", config.issueUrlFormat);

/*
fork icon2
star icon2
watch icon0

+ 5 other calls in file

639
640
641
642
643
644
645
646
647
648
if(!template) {
    continue;
}

try {
    Handlebars.registerPartial(allPartials[i], template);
} catch (e) {
    this.errorLog.push({
        message: 'An error (1001) occurred during parsing ' + allPartials[i] + '.hbs partial file.',
        desc: e.message
fork icon341
star icon0
watch icon79

+ 2 other calls in file

78
79
80
81
82
83
84
85
86
87
88
}


function registerPartials (src) {
  return vfs.src('partials/*.hbs', { base: src, cwd: src }).pipe(
    map((file, enc, next) => {
      handlebars.registerPartial(file.stem, file.contents.toString())
      next()
    })
  )
}
fork icon2
star icon0
watch icon2

122
123
124
125
126
127
128
129
130
131
const emitPartialRegistration = (path, resourceName) => {
  const baseName = path.split('/').pop()
  if (baseName.startsWith('_')) {
    const virtualPath = path.slice(canvasDir.length + 1)
    return `
      Handlebars.registerPartial('${virtualPath}', templates['${resourceName}']);
    `
  }
  return ''
}
fork icon0
star icon0
watch icon0

+ 2 other calls in file

635
636
637
638
639
640
641
642
643
644
  console.log('Loading page templates.')
}

// Template for all pages Header and Footer
const pageTpl = await Files.loadTemplate(config.templatesDir, templateType, 'page.html')
Handlebars.registerPartial("page", pageTpl)
const sharingTpl = await Files.loadTemplate(config.templatesDir, templateType, 'sharing.html')
Handlebars.registerPartial("sharing", sharingTpl)

// Templates for the main site pages
fork icon0
star icon0
watch icon0