expressjs / generator

Express' application generator
MIT License
1.82k stars 545 forks source link

Option for Nunjucks Engine Support #156

Open iamchathu opened 7 years ago

iamchathu commented 7 years ago

Add support for Nunjucks engine as an option.

gokaygurcan commented 7 years ago

This was requested before in #87 and I remember I did that in #119

This was the last comment from @dougwilson about the PR:

Thanks again for the PR, though! It is perfectly fine, the only real reason I'm even closing it is that it seems like the used module is really weird as-is and the maintainers don't even want to bother with the Express/js integration.

And I believe he's right about this.

There's this package though: https://github.com/pkolt/express-nunjucks maybe that'll be more useful. If you think that this is a good addition/feature, than I can pick it this evening.

iamchathu commented 7 years ago

I went though the links and saw that Nunjucks maintainers need to remove support to express! I liked Nunjucks syntax since it heavily burrowed features from swig which is not now not maintained. But Nunjucks have syntax highlighter plugins for major IDEs and text editors.

I think using express-nunjucks rather than Nunjucks seems good for future.

Gchesta commented 7 years ago

Nunjucks is a stable Templating engine supported by mozilla and Extremely robust. It's also ideal for people coming from Django and Flask (Python). I don't undertand why people should need to install another package (Express Nunjucks) just to handle this template.

dougwilson commented 7 years ago

Hi @Gchesta you should let Mozilla know you want them to support Express. You can let them know here: https://github.com/mozilla/nunjucks/issues/611 . Mozilla is the ones who think you should install another package to handle their template language (see their own issue https://github.com/mozilla/nunjucks/issues/611).

ashwin31 commented 7 years ago

Hi @dougwilson I am from django background, I like express and nunjucks, can you see if some one can fix these https://github.com/mozilla/nunjucks/labels/express they don't see anyone fixing issues related to express and that could be the cause for raising mozilla/nunjucks#611

dougwilson commented 7 years ago

Hi @ashwin31 thanks for that information! I don't know anyone who I can nominate to fix the issues, but if you happen to know anyone, definitely send them on over there :) !

coderam commented 6 years ago

hi, @gokaygurcan -- would you be able to add the nunjucks support for the generator? it has been requested much because so many people have been moving over from django and django uses essentially nunjucks templating.

ghost commented 6 years ago

I just forked this at https://github.com/windysurf/generator and made changes to express-cli.js still needs to be finalized. can anyone lend a hand?

ghost commented 6 years ago

update to my fork, i attempted a local install of my forked ./generator folder, then ran an express --view=nunjucks generator-test --- sorry to say eveything was good but did not copy my index.html, layout.html and error.html to the views folder. I am new to node from Django so could use a hand here. @dougwilson (maybe you can checkout my code and see if something funny stands out. and of course, @gokaygurcan if you still have the desire to help, i have everything mostly complete, but could use a hand.

gokaygurcan commented 6 years ago

Hi @windysurf, I cloned your repo (windysurf/generator) and ran it:

node .\bin\express-cli.js --view=nunjucks nunjucks-test

   create : nunjucks-test
   create : nunjucks-test/package.json
   create : nunjucks-test/app.js
   create : nunjucks-test/routes
   create : nunjucks-test/routes/index.js
   create : nunjucks-test/routes/users.js
   create : nunjucks-test/public
   create : nunjucks-test/views
   create : nunjucks-test/views/index.html
   create : nunjucks-test/views/layout.html
   create : nunjucks-test/views/error.html
   create : nunjucks-test/bin
   create : nunjucks-test/bin/www
   create : nunjucks-test/public/images
   create : nunjucks-test/public/javascripts
   create : nunjucks-test/public/stylesheets
   create : nunjucks-test/public/stylesheets/style.css

   install dependencies:
     > cd nunjucks-test && npm install

   run the app:
     > SET DEBUG=nunjucks-test:* & npm start

It seems index.html, layout.html and error.html are copied from templates/nunjucks folder to views folder. They are exactly the same.

In the meantime, I needed to fix a typo in bin/express-cli.js line 54. I'm not sure what the problem is, but I can help you if you need.

ghost commented 6 years ago

Fixed line 54, thanks for that @gokaygurcan . I created a test-project folder then npm install . in that folder, then attempted to run "node app.js" on the generated folder, but nothing runs and the terminal does not spit out any output. Any ideas?

ghost commented 6 years ago

hi @gokaygurcan, i pushed to my forked repo the typo, but beyond that my programming abilities waver. Do you think you could take the "front-end" of what I changed and finalize it making sure that the templates render? It would be a major goodness as Django uses the same templating so people can start coming over in your merit!

ghost commented 6 years ago

@dougwilson (and hopefully @gokaygurcan), if you checkout my fork for generator, the front-end of this is mostly done, just need a little help from an experienced Noder to wrap it up. the --nunjucks option works and the files are generated... needs a bit of testing.

dougwilson commented 6 years ago

Sorry I have been away an unable to take a look myself yet. You're always welcome to make a pull request even if you are not done (you can state that in your PR). It makes it quick and easy to see the changes and CI status. I can even hell directly by pushing to the PR too, no worries. I can help with anything related tl the generator, but know nothing about nunchucks.

ghost commented 6 years ago

@dougwilson thanks, a schizophrenic first attempt :)

ghost commented 6 years ago

@gokaygurcan @dougwilson created pull request with nunjucks :)