shannonmoeller / handlebars-wax Goto Github PK
View Code? Open in Web Editor NEWThe missing Handlebars API for data, partials, helpers, and decorators.
Home Page: http://npm.im/handlebars-wax
License: MIT License
The missing Handlebars API for data, partials, helpers, and decorators.
Home Page: http://npm.im/handlebars-wax
License: MIT License
The markdown helper in handlebars-helpers
allows you to pass in an options object containing options for the marked
module. There is currently no way to this via registrar
:
var handlebars = require('handlebars'),
markdown = require('handlebars-helpers/lib/helpers/helpers-markdown');
markdown(handlebars, { marked: { ... } });
I'm trying to load handlebar partials into both metalsmith-layouts and metalsmith-hbt-md because I first process markdown as mustache, then convert to HTML, then insert into the layout which is also mustache.
It appears that you're using require(partialFilename)
. When it's HTML, I get the following error:
/home/user/project/layout/partials/content.html:1
(function (exports, require, module, __filename, __dirname) { <div class="D(tbc) W(100%)">
HTML isn't valid JS, so the cause of the error is obvious. Can arbitrary extensions be made to work?
Opening this issue to track the fix for the root cause of shannonmoeller/gulp-hb#42.
"TypeError helper.apply is not a function"
I'm using handlebars-wax via gulp-hb to build a static site - this has been working fine for a couple of years but the upgrade of handlebars broke the build.
"access to prototype properties is forbidden completely by default, specific properties or methods can be allow via runtime-options. See #1633 for details."
https://github.com/wycats/handlebars.js/blob/master/release-notes.md - it might be a flag needs to be set now. Happy to try and fix and issue a PR if you have no time.
So I've been reading trying to find an answer which led me to here from gulp-hb
.
Issue I'm having is trying to extract path from component name. I am using parsePartialName
like so
module.exports = function(gulp, cb) {
return gulp.src(paths.html)
.pipe(hb()
.partials('./app/components/**/*.{hbs, js}', {
base: path.join(__dirname, '../app/components'),
parsePartialName: function(options, file) {
return file.path
}
})
.helpers('./helpers/*.js')
)
.pipe(rename({
extname: '.html'
}))
.pipe(gulp.dest('./build'))
.pipe(plugin.connect.reload())
.on('error', plugin.util.log);
};
The issue I'm running into is I want to be able to include all sub-folders as well. Doing the above way I still have to type the folder in components
folder.
{{> button/button
classes="button__primary"
}}
It would be better if I could glob the directory and just use
{{> button
classes="button__primary"
}}
Is that possible or is it an issue with conflicts. If I have 2 different button directories I need to specify which one I'm going to use so the parser will know?
I'm thinking about switching the bustCache
default to true
at this level. Having a hard time thinking of a situation where I wouldn't want that to happen with this lib.
If you add partial folder and load it (at least with gulp-hb), partial names look like an absolute path from C: instead of just "partials/layouts". The problem lies in keygenPartial function, as it assumes forward slashes in the path. Problem is solvable by replacing
var shortPath = file.path.replace(file.base + '/', '');
with
var shortPath = file.path.replace(/\\/g, '/').replace(file.base.replace(/\\/g, '/') + '/', '');
Handlebars uses the @root
variable to mean the object that's passed into the template. handlebars-wax
is overriding that value to mean globally registered data. That's the root cause of shannonmoeller/gulp-hb#49 and unic/estatico#36.
Instead of overriding @root
, two new @
variables should be introduced:
@global
: Reference to the globally registered data (formerly @root
).@local
: Reference to the data passed into a template created with wax.compile
.@root
: Reverts to default Handlebars mechanic. In wax
terms, that means @root
will be equivalent to Object.assign({}, global, local);
.the default partial parsing method is not work in my terminal integrated in vscode
for the following replacement not work
var shortPath = fullPath.replace(basePath, '');
fullpath is C:/xxxx/xx.hbs
and the basePath in my env is c:/xxxx/
so my workaround is your config option like this:
var shortPath = fullPath.replace(new RegExp(basePath,"i"), '');
maybe you should fix this
im using your gulp-hbs and was trap by this
Hi, thanks for you work. This module is very helpful.
I have a question. Is it possible to extend handlebars-wax
to use yaml (and/or json5) in data files?
Regards
I use s3 as my filesystem so while I want to use wax, cant as it is obviously based on local fs. Would love to discuss an approach to add the ability to pass in a fs binding.
Hi, it's me again (#6).
Just one more question. Is it possible to produce an error when partial used in template was not found? I caught myself checking resulting html file multiple times.
Regards
Would you consider updating this package and releasing it again so I don't have vulnerabilities listed when I use this? The problem isn't this package, nor one of its immediate dependencies, but it can be fixed when using a newer require-glob.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.