Need a fast template development environment? You're in the right place ^_^
You will have these when using it;
- Twig Template Engine
- SASS to CSS Compiler
1- Clone the repo;
git clone https://github.com/gurkanbicer/node-template-dev-env.git
2- Install packages;
npm install
3- Run;
npm start
- ExpressJS 4 (documentation)
- Twig (documentation)
- Sass (documentation)
When you need create an another page, you should write your code into routes/index.js file. Here an example;
router.get('/books', function (req, res) {
const params = {
title: 'Page: /books',
books: [
{"name" : "Hello World!"},
{"name" : "Hello JS!"}
]};
res.render('books', params, function (err, output) {
writeOutputToDist(req.path, output);
res.send(output);
});
});
Then, create a twig file into views directory.
<h1>{{ title}}</h1>
<ul>
{% for book in books %}
<li>{{ book.name }}</li>
{% endfor %}
</ul>
Just, open the browser and check it. Your's default url is https://localhost:3000
- Assets directory: public/assets
- Dist (output) directory: public/dist
- Views directory: views
- Route file: routes/index.js
- Config file: .env
You should run the project before use it;
npm run build-dist
When use this command public/dist directory will be emptied and re-generated.
For further information please contact or create an issue.