Skip to content

Macro support#381

Open
mmarcon wants to merge 4 commits intosintaxi:masterfrom
mmarcon:master
Open

Macro support#381
mmarcon wants to merge 4 commits intosintaxi:masterfrom
mmarcon:master

Conversation

@mmarcon
Copy link

@mmarcon mmarcon commented Nov 13, 2014

This pull request introduces the concept of macro (maybe it can be named something more meaningful).

Applications built with harp can include a _macros folder in the project root and add node.js modules into this folder. Functions and objects exported by modules will be available in the global scope and accessible from templates as

<%- macros.someFunction() %>

This helps keeping code/logic out of templates and avoid code like http://harpjs.com/recipes/blog-sitemap.

It opens up harp to lots of freedom for more expert developers who want a more customized harp experience.

Choose a reason for hiding this comment

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

You should not look if it exists, you should just try to read it and then catch the error there, now your are essential reading the dir twice.

Copy link
Author

Choose a reason for hiding this comment

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

I tend to avoid try/catch based programming, but I understand your point about performance. I can change that.

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.

2 participants