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

Allow Express to use pithy as view engine #9

Closed
wants to merge 1 commit into from

Conversation

rafis
Copy link

@rafis rafis commented Jul 18, 2016

resolves #8

@derhuerst
Copy link

I don't think an Express view engine belongs into this module. As it is common in the JavaScript ecosystem, you could create a express-pithy module and join others.

@derhuerst
Copy link

Also, require is synchronous and therefore hurts Node.js in its asynchronous nature.

@rafis
Copy link
Author

rafis commented Jul 19, 2016

require is auto-cachable, and all other view engines do the same: first time view render request recieved, it prepared by view engine and cached somethere. Of course you can pre-cache all views at application startup as you shown in your examples, but that should be done per project and described in README.md.

express-pithy will require to maintain project which I do not want to do.

I saw another flaws in pithy:

  • It is allowed to specify multiple ids per tag html.div('#id1#id2'), but this should be disallowed as it is disallowed in HTML spec.
  • It does not supports branching and loops. I need html.div(null, [function() { if (something) { return html.div(null, 'bla-bla-bla'); } else { return html.div(null, 'yadda-yadda-yadda'); }]).
  • Small optimizations can be done like removing useless function attrPairs().

So perhaps I will create my own library, but not open-source.

I'm currently reading blog of @caolan , it is very cool.

@derhuerst
Copy link

require is auto-cachable, and all other view engines do the same: first time view render request recieved, it prepared by view engine and cached somethere.

But the template files are being loaded asynchronously. require loads synchronously.

  • It is allowed to specify multiple ids per tag html.div('#id1#id2'), but this should be disallowed as it is disallowed in HTML spec.

You're right. The question is if this should be enforced by pithy.

  • It does not supports branching and loops. I need html.div(null, [function() { if (something) { return html.div(null, 'bla-bla-bla'); } else { return html.div(null, 'yadda-yadda-yadda'); }]).

What about this?

html.div(null, [
    something
        ? html.div(null, 'bla-bla-bla')
        : html.div(null, 'yadda-yadda-yadda')
])

So perhaps I will create my own library, but not open-source.

Why not? It may help other people.

@derhuerst derhuerst mentioned this pull request Jul 19, 2016
@rafis rafis closed this Aug 30, 2016
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.

How to use in expressjs?
2 participants