squirrellyjs / squirrelly

Semi-embedded JS template engine that supports helpers, filters, partials, and template inheritance. 4KB minzipped, written in TypeScript ⛺
https://squirrelly.js.org
MIT License
635 stars 83 forks source link

Make an example project, using Squirrelly, for beginners #65

Closed nebrelbug closed 4 years ago

nebrelbug commented 6 years ago

A good project would be fairly simple, and well commented. Steps:

  1. Create new project using Squirrelly
    • It could use Express, or run as a web page, or something else
  2. Upload project to Github
  3. Comment here with the link--we'll probably put it in cheatsheet.md or the online docs or wiki
Jayadev6191 commented 6 years ago

@nebrelbug Can I take this ?

nebrelbug commented 6 years ago

@Jayadev6191 that would be great!

nebrelbug commented 5 years ago

@Jayadev6191 do you have any questions?

Jayadev6191 commented 5 years ago

@nebrelbug I have started working on this with an express app. I will am planning to build a simple page application which incorporates all the functionalities of the library. Once I figure out how to use all the features (e.g building my own squirrelly custom helpers) I will add meaningful content to the project.

example-project Please let me know if I'm on the right path or something needs to be changed in the way that I'm building the example project.

nebrelbug commented 5 years ago

@Jayadev6191 I actually just found a bug with Squirrelly and Express ☹️. Hopefully I'll have it fixed by tomorrow, but pause on your repo until then. Thanks!

Jayadev6191 commented 5 years ago

No worries. Thanks for letting me know!

nebrelbug commented 5 years ago

Hi @Jayadev6191! I just pushed changes that should fix the problem (along with adding caching, which should make everything a lot faster) to the fsprob branch.

After a little more testing, I'll merge the changes to master and publish a new version on NPM, hopefully by the end of tomorrow. At that point, you'll be able to work on it :)

Jayadev6191 commented 5 years ago

Hi @nebrelbug great! Please let me know once you publish it :) Also, can you explain how that bug that you are trying to fix is blocking me from making additional changes ?

nebrelbug commented 5 years ago

@Jayadev6191 Squirrelly exports Sqrl.__express, which makes it so that you could follow a tutorial like this: https://expressjs.com/en/guide/using-template-engines.html, just installing Squirrelly instead of Pug, and making an index.squirrelly. It handles caching and rendering for you, so you don't have to do it all by hand.

nebrelbug commented 5 years ago

@Jayadev6191 I just published 6.0.0-beta. You can install that by npm install squirrelly@beta, and then you should just be able to follow a tutorial like the one above and create a repo without much trouble. I'm going to work a couple of days on testing and minification before I publish without beta, but you can get started as soon as you want. Thanks!

Jayadev6191 commented 5 years ago

Hi @nebrelbug sounds great! I will continue working on the example project without the beta. Thanks! :)

nebrelbug commented 5 years ago

@Jayadev6191 I just published version 6.0.1. Working with Squirrelly and Express should be lots easier now--just follow the instructions here: https://expressjs.com/en/guide/using-template-engines.html but with Squirrelly. Thanks!

Jayadev6191 commented 5 years ago

Thank you sir! Will work on this today and tomorrow.

Jayadev6191 commented 5 years ago

@nebrelbug The changes you made for the package(to make it work on express) expects the template files to have any specific extension (for e.g ) ? Please confirm. I made changes to my main file to have a view engine and passed Sqrl object to it.

let express = require('express');
let path = require('path');
let Sqrl = require("squirrelly");
let app = express();

app.set('view engine', Sqrl)
app.set('views', path.join(__dirname, 'views'))

Please let me know if this is the right way to set the template engine for squirrelly.

nebrelbug commented 5 years ago

That looks good! It expects files to have the extension .squirrelly, so for example index.squirrelly. I know you can just do app.set('view engine', 'squirrelly'), but your way might work too. You should also just be able to app.set('views', './views'). Thanks!

nebrelbug commented 5 years ago

@jeanha124 do you need any help? Here's a link that might be useful: https://squirrelly.js.org/recipes/squirrelly-with-expressjs. Thank you!

Jayadev6191 commented 5 years ago

@nebrelbug Was that meant for me ? If yes, You've tagged a different person! 😀 I made some progress on the https://github.com/Jayadev6191/squirrelly-example-project

I looked at your codepen example to see how you have used custom Helpers which was not very clear. I might spend sometime on that and get back to you over the weekend.

Thanks, Jay

nebrelbug commented 5 years ago

Sorry @Jayadev6191!

saeedcs commented 4 years ago

@Jayadev6191 How do we include one template file into another, any assistance in this matter will be appreciated

hrsetyono commented 4 years ago

Hi just want to contribute an example as a non-Node developer:

https://codepen.io/hrsetyono/pen/gOOZWgW

This basic usage in HTML is missing in the Learn section. We might think it's obvious how to do it, but lots of beginners will find this easier to grasp.

nebrelbug commented 4 years ago

@hrsetyono this is great! Would you like to put together a pull request to add this to the docs?

If not I'll add it, probably under Resources / Examples :smiley:

hrsetyono commented 4 years ago

@nebrelbug Glad you like it. Feel free to add it to the Resources / Examples.

Maybe it's better to expand it a little to include For loop and IF conditional