by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jul 04 01:36
    nebrelbug commented #196
  • Jul 04 01:10

    nebrelbug on gh-pages

    docs(docs): update gh-pages (compare)

  • Jul 04 01:08

    nebrelbug on v8.0.3

    (compare)

  • Jul 04 01:08

    nebrelbug on master

    Update README - add note about … v8.0.3 (compare)

  • Jun 22 16:51
    vinothbabu commented #195
  • Jun 21 00:03
    nebrelbug commented #195
  • Jun 21 00:02

    nebrelbug on gh-pages

    docs(docs): update gh-pages (compare)

  • Jun 21 00:01

    nebrelbug on gh-pages

    docs(docs): update gh-pages (compare)

  • Jun 21 00:00

    nebrelbug on v8.0.2

    (compare)

  • Jun 21 00:00

    nebrelbug on master

    v8.0.2 (compare)

  • Jun 20 23:59

    nebrelbug on master

    Update some tests to import fro… Rebuilt (compare)

  • Jun 20 23:09

    nebrelbug on master

    Upgrade dev dependencies (compare)

  • Jun 20 23:02

    nebrelbug on gh-pages

    docs(docs): update gh-pages (compare)

  • Jun 20 23:01

    nebrelbug on master

    check if the native prototype m… check if the function exists in… Revert "check if the function e… and 2 more (compare)

  • Jun 20 23:01
    nebrelbug closed #195
  • Jun 14 01:09
    Arturace closed #196
  • Jun 14 01:09
    Arturace commented #196
  • Jun 14 00:33
    Arturace commented #196
  • Jun 14 00:33
    Arturace edited #196
  • Jun 14 00:13
    Arturace opened #196
Ben Gubler
@nebrelbug
Hi @FrankMono, that's a strange issue! I'll look into it this afternoon. In the meantime, would you be averse to using Squirrelly v8?
Here's what your template would look like with v8:
<div>
{{~each(it.items) => val}}
  <div>
  {{~each(val.inner) => innerVal}}
    <p>{{innerVal.title}} + {{val.text}}</p>
  {{/each}}
</div>
Kazumasan
@Kazumasan
hey how would you work with sqrl in a browser and is it possible to work with it in a .sqrl file extension like style ?
Ben Gubler
@nebrelbug
@Kazumasan to use Squirrelly in the browser, you'll first need to include the CDN:
<script src="https://unpkg.com/squirrelly@7"></script>
That makes Squirrelly available as the global variable Sqrl.
As far as working with .sqrl file extensions, it should be completely possible. Just use a JavaScript fetch() to fetch the file, then render it. Let me know if this works!
Kazumasan
@Kazumasan

it does work its however a relatively clunky way (i think) however i lack a better solution thanks!

would be nicer to include it like it would be a file in the file system but i know thats not possible.

Ben Gubler
@nebrelbug
@Kazumasan you could also rewrite the include nativeHelper to make the front-end less confusing...
Kazumasan
@Kazumasan
a native helper would be a smoother way maybe its something to add into squirrelly altogether i really like the project but i yet fail to find a streamlined workflow with it that provides good code structuring. Any suggestions ? And what do you think are the best use cases for squirrelly ?
Ben Gubler
@nebrelbug

@Kazumasan I think the best use cases for Squirrelly are where you have to generate static assets, static websites, make site layouts, etc. Ghost.org, for example, uses Handlebars in writing themes, which I think is a great example of a good use case.

As far as workflows, I don't know! You could look at popular projects which use template engines and see what their workflow looks like

Simon Fremaux
@dievardump
Hi :) is there any way to change this horrible ~ by an @ or anything else easier to type with only one hand on an azerty keyboard?
Ben Gubler
@nebrelbug

@dievardump that makes a lot of sense! I'll look into adding a feature for that this afternoon :)

I'm honestly tentatively considering switching it to an @ by default since I think it might look cleaner...

Kazumasan
@Kazumasan
opinion on scoped styles ?
Ben Gubler
@nebrelbug
@Kazumasan I'm not quite sure what you mean... ?
Kazumasan
@Kazumasan
a way to keep styles just to the template similar to what Vue does with <style scoped>
Ben Gubler
@nebrelbug
@Kazumasan that sounds very nice. I think that's a little out of the scope of Squirrelly, but I'm sure there's a way to get something like that working using some additional tools!
Ben Gubler
@nebrelbug

@/all quick announcement:

While I'm finishing the last touches on Squirrelly, check out Eta! It's a template engine with the same internals as Squirrelly, and is designed as a faster and more lightweight alternative to EJS. It solves parsing problems that both EJS and doT have, and supports plugins!

dpeter99
@dpeter99
Hey guys I'm trying to set up a simple view template
But I can't get it to include my page files.
(I'm trying to have a single template file for the website, and many smaller files for the content in that would get included in the template based on the URL)
Ben Gubler
@nebrelbug
@dpeter99 sorry for the late reply!
In Squirrelly v7, you have to define the partial first:
fs.readFile('/views/partial1.sqrl', (err, template) => {
  if (err) {
    console.error(err)
    return
  }
  Sqrl.definePartial("partial1", template)
})
Then you can use it in your template like:
{{include("partial1")/}}
I know that's a huge pain, and Squirrelly v8 lets you just do {{~includeFile('./partial1') /}}. It will be released shortly.
Mike Dalrymple
@mousedownmike
The v8 docs show the use of the @ sign in an example but I can't figure out what the meaning of the symbol is. https://squirrelly.js.org/docs/syntax/helpers
{{@user.img}}
Also... is there an idiomatic way of accessing process.env variables in a template? I'm just manually passing it in as something like it.env.
Ben Gubler
@nebrelbug
@mousedownmike shoot it looks like I forgot to edit that from the v7 docs. In v8 that wouldn't be valid syntax :)
As far as accessing process.env, the best way is probably the way you're doing it.
Although actually, if process.env is in the global scope, you may be able to access it from within the template.
Mike Dalrymple
@mousedownmike
👍
Ben Gubler
@nebrelbug
@mousedownmike since it seems you're one of the first users (or potential users) of version 8, can I ask a quick question?
I've been thinking about changing the prefix marking helpers from ~ to @. I think it might potentially improve readability and make templates easier to type for people with international keyboards.
My change would allow people to customize prefixes (change it back to ~ if they wanted), but it would set @ as the default helper prefix (ex. {{@myhelper("stuff") /}})
Any opinions on this?
Mike Dalrymple
@mousedownmike
I find the tilde difficult to distinguish from a hyphen... in Go {{- removes whitespace in a template. So... as a sampling of 1, I agree with your intuition to change it to @.
Ben Gubler
@nebrelbug
:thumbsup:
Ben Gubler
@nebrelbug
@/all as a warning, the next Beta release will contain a breaking change: helpers will be prefixed by @ instead of by ~ by default.
Prefixes will be customizable in the coming release, but after a lot of consideration I decided @ would be better as a default prefix.
Mike Dalrymple
@mousedownmike
@nebrelbug I wrapped up my initial implementation using v8 last week. It's a pretty basic AWS Lambda function that uses Squirrelly to format messages generated by AWS Cognito. Super fast and so far... super reliable. Thanks!
Ben Gubler
@nebrelbug
@mousedownmike you're welcome! I'm glad you're enjoying using Squirrelly!
Don't Ask
@DontAskM8
Hi wanna ask how do i actually get the previous key of a loop
{{foreach(options.items)}}
    <tr>
        {{foreach(options.items[@key])}}
        <td>{{@../key}}</td>
        {{/foreach}}
    </tr>
{{/foreach}}
The above is just part of the code. Others are working fine and im getting TypeError: Cannot read property 'id' of undefined
John Jenkins
@johnjenkins
Hi there! Just wondering if there's a in built way of temporarily storing a local variable within the template or anything?
I want to sum the number of items in an array of objects. Thought about making a helper using reduce or whatever, but it would be so specific in this case that defining a helper seems over the top.
Is there a way I can temporarily store a count using ~each or something?
Thanks!
Ben Gubler
@nebrelbug
@johnjenkins sure! You should be able to do something like this:
{{js(var x = 0)/}}
{{foreach(options.obj) }}
hey
{{js(x += @this.length)/}}
{{/foreach}}
Note that x is a global variable, so it can only be accessed inside function parameters
John Jenkins
@johnjenkins
Great! Totally forgot to mention I'm using v8(!) but pointed me in the right direction.
I achieved what I needed to with {{ (it.appliedFilters.reduce(function(a, b) { return ... }, 0)) }}
Ben Gubler
@nebrelbug
@johnjenkins fantastic!

@DontAskM8 after doing some investigation, it looks like that's a bug in Squirrelly v7. Squirrelly looks back up the scope chain one too many times with scoped helper references. Squirrelly v7 doesn't have automated testing, and not many people use scoped helper references, so that must be how the bug wasn't noticed.

Unfortunately, I don't believe there's an easy way to fix the problem -- hundreds of templates use Squirrelly v7, and this would be a breaking change for people with scoped templates.

I would recommend just using Squirrelly v8 stable, which I will release later this week. It is more powerful, remains lightweight, and has automated testing and test coverage set up.
Don't Ask
@DontAskM8

I would recommend just using Squirrelly v8 stable, which I will release later this week. It is more powerful, remains lightweight, and has automated testing and test coverage set up.

Alright will update soon. Anyways found a workaround by using ids for loop. The documentation actually lacks this information and only found it in the comment section