Improved Jade package

I’ve released dalgard:jade version 0.5.0 as a fork of mquandalle:jade with a small set of improvements that I thought were important.

My motivation came from the fact that there hasn’t been any activity on the original package in the last five months, and I needed a few changes to better support the dynamic attribute helper in dalgard:viewmodel.

Here are the highlights:

  • Arguments in interpolation: #{helper posArg keyword='cool'} (a parenthesis version exists for keeping consistent with ↓)

  • Arguments in attributes: element(attribute=helper(posArg keyword='cooler'))

  • Shorthand for dynamic attributes: element($attr)<element {{attr}}>

Check out the readme in the repo for more info.

4 Likes

Now this looks interesting. Thanks a lot! I’ll be sure to test it thoroughly. :wink:

1 Like

Looks like extrapolated args work perfectly! Many thanks for taking the time to fix this, @dalgard.
I’ll try to test the other features on my current project and report back if I find anything strange.

2 Likes

Thanks @bkuri. Yesterday I discovered two corner cases that the tests caught, but I missed. I’m fixing them today or tomorrow. I don’t expect they would be a problem for anyone today, but they might pop up for someone some day.

I have fixed the corner cases in dalgard:jade version 0.5.3, so all tests are now passing and new tests have been added for the extended syntax.

1 Like

Version 0.5.1 extended parenthesis syntax to include components, includes, and built-ins. Version 0.5.4 of dalgard:jade adds support for @index and fixes a console error.

Is there a good way to request an update or file a bug report? I noticed forked repos don’t have an “issues” section on GitHub.

Basically, what I’m trying to do is

each items
    +item
else
    +loading

Each/Else and With/Else are both supported in Blaze (although I didn’t know that until a couple days ago). And I just tried to use it with your Jade package and it doesn’t work :frowning:

If you could update it to allow for that, that would be amazing :smile:

I do it this way:

unless items
  +loading
else
  each items

@sircharleswatson: Sorry about the issues section – apparently it was necessary to enable it manually.

It surprises me that else blocks don’ work with each and with. My fork haven’t touched that part of the code, so I think you should create an issue under the original mquandalle:jade package. I will take a look at it there, then.

Please note, that Jade will be deprecating string interpolation #{var} in favour of es6 syntax #[var].

1 Like

@niallobrien: Thanks for the heads-up. What do you mean by ES6 syntax, exactly? It looks like the syntax for tag interpolation.

Yes, apologies - you’re right. With Jade, it’s specifically related to interpolation in attributes. See https://github.com/jadejs/jade/issues/2095

@brajt

That’s the way I’m doing it now, just wanted to avoid the extra nesting

2 Likes