Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jan 18 20:47
    nebrelbug commented #14
  • Jan 18 18:36
    dhuang612 commented #14
  • Jan 02 18:22
    fatganz commented #135
  • Jan 02 18:13
    nebrelbug commented #135
  • Jan 02 18:07
    fatganz edited #135
  • Jan 02 18:07
    fatganz opened #135
  • Dec 30 2019 01:08
    greenkeeper[bot] commented #134
  • Dec 22 2019 02:09
    greenkeeper[bot] labeled #134
  • Dec 22 2019 02:09
    greenkeeper[bot] opened #134
  • Dec 22 2019 02:07

    greenkeeper[bot] on initial

    chore(package): update dependen… docs(readme): add Greenkeeper b… chore(package): update lockfile… (compare)

  • Dec 19 2019 17:27
    nebrelbug commented #106
  • Dec 17 2019 07:53
    pke commented #106
  • Dec 15 2019 19:28
    nebrelbug commented #120
  • Dec 12 2019 02:29
    hustcer commented #132
  • Dec 10 2019 20:51
    nebrelbug commented #132
  • Dec 10 2019 17:55
    clitetailor commented #120
  • Dec 03 2019 17:40
    jasonfutch commented #132
  • Nov 20 2019 14:03
    hrsetyono commented #65
  • Nov 20 2019 14:02
    hrsetyono commented #65
  • Nov 18 2019 23:49

    nebrelbug on master

    v7.9.0 (compare)

Ben Gubler
@nebrelbug
@saeedcs try something like this (taken in part from @scottkipfer_twitter's fastify plugin):
const Sqrl = require("squirrelly");
const path = require("path");
const klaw = require("klaw-sync");
const fs = require("fs");

const partialsDir = path.join(cwd, "/partials");

const paths = klaw(partialsDir, { nodir: true })

// Loop through each path
paths.forEach(({ path }) => {
  // get template content
  const file = fs.readFileSync(path);
  // convert file name to a template name
  const importName = path
    .split(dir)
    .join("")
    .replace(/\.[^/.]+$/, "")
    .replace(/^\//g, "");
  Sqrl.definePartial(importName, file);
});

Sqrl.defineHelper("include", function(args, content, blocks) {
  //Do whatever you want here with the arguments, blocks, and content, then return a string
  return Sqrl.P[args[0]](args[1]);
});
saeedcs
@saeedcs
HI Ben, Thanks for your reply, I will try it out and let you know how it goes
Ben Gubler
@nebrelbug
@/all I've decided to release one more version between the current version and the version with a custom parser. See details at #132
Please respond w/ any feedback!
rmvedas
@rmvedas
fantastic work @nebrelbug !
If you are around would love to have a quick chat. cheers
dtrikannad
@dtrikannad
@nebrelbug That sample code is awesome! Thank you for sharing it!
Ben Gubler
@nebrelbug
@dtrikannad I'm glad it was helpful!
@rmvedas thanks! I'd love to chat -- DMing me on Gitter is probably easiest
msaus
@msaus
Hello. Is this faster than this template engine? https://github.com/aui/art-template
Ben Gubler
@nebrelbug
Hi @msaus! As of right now, Squirrelly comes in second behind Art-template when I add it to the Art-template benchmarks. However, Squirrelly supports many features Art-template does not, like filters
msaus
@msaus
HI @nebrelbug ! Thanks for your information. Do you think you can increase performance?
Ben Gubler
@nebrelbug
@msaus that's the goal! Actually, I'm working on the next version right now which should have significantly increased performance :)
msaus
@msaus
@nebrelbug Great! I may wait for it:) Possibly, it would be released next year?
Ben Gubler
@nebrelbug
@msaus Actually, it will hopefully be released by around Jan 20
msaus
@msaus
@nebrelbug Oh! Thats quick. I may start using it from next week.
Clément Lakhal
@clemlak
Hello :)
Quick question guys, is there a way to get syntax highlighting somehow?
I'm working on a relatively big template and it's getting confusing sometimes
Ben Gubler
@nebrelbug

Hi @clemlak! As of right now I haven't built any syntax highlighting plugins. I plan on building some with the next release of Squirrelly sometime next year.

However, if you wanted to build one, it shouldn't take much work at all! See

Clément Lakhal
@clemlak
Thanks for your reply :)
I might give it a shot actually, I’m using Squirrelly for a project and I might need to create several templates in the future
I’ll let you know :)
Ben Gubler
@nebrelbug
:thumbsup: you should do it!
Clément Lakhal
@clemlak
Capture d’écran 2019-11-27 à 09.18.31.png
Still needs some work but we’re getting there :)
Ben Gubler
@nebrelbug
@clemlak looks great!
Clément Lakhal
@clemlak
Thanks!
Ben Gubler
@nebrelbug

@msaus another thing that I just realized is that art-templateis about 100KB minzipped, compared to Squirrelly, which is about 2KB minzipped.

Squirrelly is 45 times smaller! Art-template is a really cool program and can match lots of scenarios quickly, but if you don't want to significantly increase bundle size, Squirrelly is your best bet :)

Brian Dijkstra
@briandijkstra_twitter
Hello, is got a question can i use nl2br or raw in the template engine.. like {{@this.description|nl2br}} or {{@this.description|raw}}
Ben Gubler
@nebrelbug
@briandijkstra_twitter sorry for the late response! You sure can, like this: {{@this.description | safe}}
Philipp Kursawe
@pke
How to do layouts in squirrely?
Ben Gubler
@nebrelbug
Hi @pke! Layouts aren't currently built in to Squirrelly, but they'll be released in the next version, which will be released sometime in January. In the meantime, you can see this Stackblitz Demo for a demo of how to manually implement them. Let me know if you have any questions!
Erik
@Coding-Kiwi
heya, just a quick question: as squirrely uses eval I have to put 'unsafe-eval' in my Content-Security-Policy. Is there a way to get around this?
Erik
@Coding-Kiwi
to be more precise: the use of new Function throws an "EvalError"
Ben Gubler
@nebrelbug
Hi @Coding-Kiwi! As of right now, I can't think of a way to get around that. I'm planning on releasing a command-line tool to precompile templates, but if you're using them at runtime there's no built-in way to not use new Function
Erik
@Coding-Kiwi
@nebrelbug I already wrote a script (npm run templates) that precompiles all my templates in the templates folder to a cache.js which I then only have to require in my app, if it would save you work I can send you the code
Ben Gubler
@nebrelbug
@Coding-Kiwi that would be wonderful!
tabarra
@tabarra
@nebrelbug Can we expect the elseif syntax soon?
Ben Gubler
@nebrelbug
@tabarra Yes! I have a working version of squirrelly-nextat https://github.com/squirrellyjs/squirrelly-next. I'll publish an alpha either tonight or sometime after the 12th
tabarra
@tabarra
Thats great news =D
masao soseki
@allgrowsm
@nebrelbug Thats great :) Then, I did not know that squirrelly is smaller than art-template. I guess this is one of the advantage. Also, I am looking forward to seeing next release as well :)
Ben Gubler
@nebrelbug
Hi everyone! I'm happy to report that the next version of Squirrelly is about ready to release! You can see the code at https://github.com/squirrellyjs/squirrelly-next :sparkles:
Cool features:
  • Much more powerful and reliable parser than Squirrelly v7, and comparable in performance
  • Plugins support
  • Filter parameters
  • I've been writing tests as I go so nothing breaks
Ben Gubler
@nebrelbug

@/all I want some feedback before I publish though.

First of all, I decided to go with doT-styled references to reference data (but without the =): {{it.someValue}}. This means that I allow what doT calls 'evaluate syntax' (just sticking in native code) like this: {{!whatever}}.

My question is whether I should switch, so you would reference variables like {{=it.name}} or {{=someLocallyDefinedVariable}} and use {{ whatever }} for evaluate syntax. The main convenience of this would be that comments would look nicer (ex. {{/*comment*/}} instead of {{!/*comment*/}}.

My other question is about publishing. Should I publish as squirrelly-next on NPM, or publish it as version 8 of Squirrelly, or choose another name (like Gopher?)
masao soseki
@allgrowsm
@nebrelbug That is good news :) Then, I prefer doT-styled reference because it is more easy to read for me. But, I guess it depends on performance. If it dose not impact on performance, please go ahead. By the way, v8 would be good for everyone because if you change the name, it makes people confused. But, this is all up to you :)
Erik
@Coding-Kiwi
@nebrelbug I prefer the syntax without the =, mainly because I then don't have to rewrite all my templates if I upgrade
Ben Gubler
@nebrelbug
@Coding-Kiwi @allgrowsm hmm... perhaps I should make this configurable depending on the user. I'll check if this would significantly impact performance