GithubHelp home page GithubHelp logo

shannonmoeller / handlebars-wax Goto Github PK

View Code? Open in Web Editor NEW
39.0 4.0 9.0 157 KB

The missing Handlebars API for data, partials, helpers, and decorators.

Home Page: http://npm.im/handlebars-wax

License: MIT License

JavaScript 100.00%
handlebars helpers partials decorators data nodejs glob expressjs

handlebars-wax's People

Contributors

shannonmoeller avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

handlebars-wax's Issues

Pass options to helpers

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: { ... } });

Unable to use arbitrary extensions for partials

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?

Upgraded to handlebars 4.6.0 and now I get an error

"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.

Globbing

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?

Change `bustCache` default to `true`

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.

#6

Partial names on Windows machine

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, '/') + '/', '');

Don't override `@root`

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);.

register partials fail for case sensitive path in my pc win10

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

Yaml data files

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

Templating errors

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

Update dependencies to eliminate minimatch 3.0.x

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.