Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add helpers from config to locals passed to template #1

Merged
merged 4 commits into from Aug 9, 2017

Conversation

jimlambie
Copy link
Contributor

Include a config setting for helpers, pointing to a directory containing helper files. Each .js helper file will be added as a property to a helperFunctions object which will be merged with locals before passing them to the template renderer.

Config

  engines: {
    pug: {
      paths: {
        helpers: 'test/workspace/helpers'
      }
    }
  }

Directory structure

helpers/
|_ trim.js

Becomes...

{
  trim: [Function]
}

Usage

h1= trim(product.name)

Copy link
Contributor

@eduardoboucas eduardoboucas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super!

@hydroes
Copy link

hydroes commented Aug 9, 2017

Looks good, seems like it will work straight out of the box once merged

@jimlambie
Copy link
Contributor Author

@hydroes Are you ready to try it out? Should be easy enough to install directly from the branch to prove it'll do what we expect it to

@jimlambie jimlambie merged commit 3a176e4 into master Aug 9, 2017
@jimlambie jimlambie deleted the feature/add-helper-functions-to-locals branch August 9, 2017 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants