Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Oct 26 15:32
    nebrelbug commented #210
  • Oct 26 15:30

    nebrelbug on master

    Re-add CodeShelter badge to REA… (compare)

  • Oct 26 15:26

    nebrelbug on master

    Remove badge (compare)

  • Oct 26 15:20

    nebrelbug on master

    Various work (compare)

  • Oct 15 18:07
    nebrelbug pinned #210
  • Oct 15 18:07
    nebrelbug opened #210
  • Sep 27 00:01
    Indribell closed #209
  • Sep 27 00:01
    Indribell commented #209
  • Sep 26 22:56
    nebrelbug commented #209
  • Sep 26 22:27
    Indribell edited #209
  • Sep 26 22:26
    Indribell opened #209
  • Sep 23 14:17
    nebrelbug commented #208
  • Sep 23 08:01
    LukaszGrela closed #208
  • Sep 23 08:01
    LukaszGrela commented #208
  • Sep 22 23:08
    nebrelbug closed #154
  • Sep 22 15:33
    nebrelbug commented #208
  • Sep 22 12:06
    LukaszGrela commented #208
  • Sep 22 10:23
    LukaszGrela opened #208
  • Sep 21 15:06
    nebrelbug commented #196
  • Sep 21 09:06
    lukeinage commented #196
Ben Gubler
@nebrelbug
@aarongerig ah, that makes sense.

@msaus the "Squirrelly - Fast" benchmark doesn't use special compilation or configuration. Instead, it uses inline embedded JavaScript instead of the @each helper to reduce overhead slightly.

Here's the "Squirrelly" template:

<ul>
{{@each(it.list) => val}}
    <li>User: {{val.user}} / Web Site: {{val.site}}</li>
{{/each}}
</ul>

And here's the "Squirrelly - Fast" template:

<ul>
{{! for (var i = 0, l = it.list.length; i < l; i ++) { }}
    <li>User: {{it.list[i].user}} / Web Site: {{it.list[i].site}}</li>
{{! } }}
</ul>
I probably should clarify that on the benchmarks page :)
Ben Gubler
@nebrelbug
@msaus Squirrelly templates compile into functions that basically do JS string concatenation, so they should have quite good performance. Maybe there's another factor in your code that is slowing it down?
msaus
@msaus
@nebrelbug @aarongerig Thanks for that. It will take a look at tha☺️
Joshua Amaju
@joshua_amaju_twitter
How to define partials when using it with nodejs (expressjs).
Ben Gubler
@nebrelbug
Hi @joshua_amaju_twitter, good question! Actually, you shouldn't have to define them ahead of time. You should just be able to write {{@includeFile("path-to-template") /}}, and Squirrelly will automatically find and load the partial. Example: {{@includeFile('partials/head.sqrl') /}}
@joshua_amaju_twitter let me know if you have any more questions!
jmmclean
@jmmclean

got a general question. my typings for typescript are screaming at me for the below

filters.define('add', (str:string, val: string) => {
     return (parseFloat(str) + parseFloat(val)).toString()
})

This works and is documented at https://squirrelly.js.org/docs/api/filter-api via the replace filter

Argument of type '(str: string, val: string) => string' is not assignable to parameter of type 'FilterFunction'.ts(2345)

Is there a bad typing out there (v8 squirrelly)

jmmclean
@jmmclean
FYI, for the above, I made squirrellyjs/squirrelly#203
Ben Gubler
@nebrelbug
@jmmclean thanks! I'll look over your PR right now :)
Ben Gubler
@nebrelbug
@jmmclean also, I noticed that you're expecting both inputs to be strings. As of Squirrelly v8.0.4, you can accept any values in your filters. So you could have:
filters.define('add', (val1: number, val2: number) => {
     return val1 + val2 // JS will automatically convert to a string when we output it into the template
})
And then write a template like:
{{ it.num | add(72) }}
jmmclean
@jmmclean
@nebrelbug reason for string input is bc I use papaparse to convert a CSV to JSON, then pipe it into squirrelly. All part of some batch processing we have.
Ben Gubler
@nebrelbug
@jmmclean ah, that makes sense :thumbsup:
Joshua Amaju
@joshua_amaju_twitter
@nebrelbug no it didn't. I tried {{@include("..partials/signup") /}} (and also with the .html file extension) from the pages directory. The partials directory is at the same level with the partials directory.
Ben Gubler
@nebrelbug
@joshua_amaju_twitter you have to use includeFile instead of include. Also, I'm guessing it should be "../partials" instead of "..partials". Let me know if that works :)
jmmclean
@jmmclean
@nebrelbug is there any reason to have the dist folder in the git repo? Normally thats dynamically created from typescript via a build process
Joshua Amaju
@joshua_amaju_twitter
@nebrelbug there should be some kind of documentation on using squirrelly with nodejs. I'm stuck guess how to also define helpers. I'll try your solution and let you know if it works.
Ben Gubler
@nebrelbug
@jmmclean hmm... I remember considering that a while ago, but ultimately deciding against it. Now that I think more about the idea, it sounds like it would have some definite advantages (especially not having to commit every time we rebuild and format).
Ben Gubler
@nebrelbug

I've been updating Eta, Squirrelly's companion project, and just added support for Deno. I'm planning to merge those changes into Squirrelly (along with some file handling improvements) soon.

However, for Deno support, we have to generate a deno_dist folder in the GitHub repo. I'm not sure whether it would confuse users to have a deno_dist folder and not a dist folder, and we would still have to commit every time.

I guess one possible solution would be to create a GitHub action that would create the deno_dist folder on every commit (removing the need to commit locally and build every PR manually).
@joshua_amaju_twitter I'm planning to update the documentation soon. Hope it works for you -- if not, hopefully I'll have some good examples by then :thumbsup:
jmclean-cnexus
@jmclean-cnexus
@nebrelbug would you like me to remove the dist dir? Im happy to do it. Unfortunately, i dont know enough about deno to figure out the CI to make it more programatic. FYI, this the jmmclean user, but a different profile
Ben Gubler
@nebrelbug

@jmclean-cnexus that would be great!

Right now I use https://github.com/sindresorhus/np to publish, but I'm not sure what the best way to generate the dist folder before publishing is. Maybe a package.json script like "release": "npm run build && np"?

jmclean-cnexus
@jmclean-cnexus
@nebrelbug thats absolutely the right way! just like when you are building an archive for an application, you would do something like npm run build && npm prune --production && npm run archive or something like that
Aaron
@aarongerig

Hi all
I'm struggling to use the @each template helper. When rendering the template, Squirrelly throws me following error:

Squirrelly Error: invalid syntax at line 17 col 48:
{[@each(it.door_icons) =&gt; image_path, index]}<div>{[image_path]}</div>{[/each]}

Here's my original piece of code:

{[@each(it.door_icons) => image_path, index]}<div>{[image_path]}</div>{[/each]}

As you can see I customized my opening {[and closing ]} tags since I'm using Squirrelly in a Twig context. It works well for the @if template helper, some custom filters and helpers. What am I doing wrong?

Btw, the syntax error in my console points to the => characters in the @each statement.
each_error.png
Squirrelly version: 8.0.8
Ben Gubler
@nebrelbug
@aarongerig hmm... it looks like your template is somehow being XML-escaped ahead of time. => is being transformed into =&gt; (&gt; is the HTML code for >) and that's resulting in a syntax error.

My guess is that Twig is XML-escaping the template? I'm not sure exactly how you're using Twig, but hopefully there's some way to disable XML-escaping on the template and check if it solves your problem.

Hope this helps :smiley:

Aaron
@aarongerig
@nebrelbug Thanks for your suggestion! It seems that Twig is not escaping it, but after retrieving the HTML in my JavaScript (I'm using the HTML5 <template> tag => https://developer.mozilla.org/en-US/docs/Web/HTML/Element/template) the HTML is escaped. 🤔
Ben Gubler
@nebrelbug
@aarongerig ah, I've run into that problem before!

Hmm... the best way might be to put your template in a script tag.

<script id="template" type="text/x-squirrelly-template">
Your template here
</script>

Since the script type is unrecognized, calling innerHTML should give you the raw inner content :). Handlebars and others recommend using the <script> tag as well.
Let me know if this helps!

Aaron
@aarongerig
@nebrelbug Thank you so much! This solved my problem. Btw, awesome rendering engine you've written here. I enjoy using it :)
Ben Gubler
@nebrelbug
@aarongerig I'm glad it fixed it! Thanks!
tabarra
@tabarra
Well, I just noticed that on the jump to v8 the filters are now also sanitized
so no "new line to <br>" filter
RIP
tabarra
@tabarra
I think you should provide some default filters
nl2br is a great one
Ben Gubler
@nebrelbug
@tabarra oops, that was another unintended effect of https://github.com/squirrellyjs/squirrelly/releases/tag/v8.0.4 :grimacing:. The best option is probably to disable auto-escaping and move auto-escaping into defaultFilter (defaultFilter is still called before all other filters, which is slightly inconsistent)
As far as default filters, I think we probably want to keep the core library size down. However, it would be awesome if someone created a filter library that would load lots of helpful filters (like nl2br, join, first, etc.) into Squirrelly.
Ben Gubler
@nebrelbug

@/all Hey everyone! Just wanted to share that Squirrelly is looking for a new lead maintainer: see squirrellyjs/squirrelly#210. As of October 28th, I will be unable to continue developing the project.

My plan is to have Squirrelly's API stabilized and well-tested by that time. We should also have fairly decent documentation, several plugins, and integrations with popular tools and server frameworks.

In case I'm unable to find a maintainer, I have backup plans to ensure that Squirrelly can continue to be developed (see the link above for more info).

Several of you on this chat have been influential in guiding Squirrelly's progress -- message me if you would like to become a maintainer! (In the link above, I listed a few maintainer requirements you should check first)

I've loved working with all of you throughout Squirrelly's development, and hope it has been a helpful tool. Best wishes to all of you!
tabarra
@tabarra
Congratz on your new job!
It will be sad to not have you on the frontline of this project tho :(
Ben Gubler
@nebrelbug
Thanks @tabarra! I've enjoyed collaborating with you.
Ben Gubler
@nebrelbug
If anybody would like to contribute to Squirrelly, I've added it to Code Shelter. They should be able to vet potential contributors and grant edit and release access :)