Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tag name interpolation not working #97

Closed
jaydenseric opened this issue May 20, 2016 · 8 comments
Closed

Tag name interpolation not working #97

jaydenseric opened this issue May 20, 2016 · 8 comments

Comments

@jaydenseric
Copy link

jaydenseric commented May 20, 2016

Picking up from comments in #95.

I found a comment revealing that tag name interpolation has actually been suported in Jade/Pug since at least 2013.

Here is an example of what we use it for (in JS Pug):

mixin button(tag)
  #{tag}.button&attributes(attributes)
    block

+button('a')(href='http://google.com') Link button text
+button('button') Ordinary button text

A work around would be if statements and a bit of duplication. This would restrict you to a whitelist of options though. In this usage example we only need to support two tags anyway.

@jaydenseric jaydenseric changed the title Tag name intrerpolation not working Tag name interpolation not working May 20, 2016
@TorbenKoehn
Copy link
Member

Ugh, now I have to implement it haha.

Thanks for the hint, I'll check if this is possible

@jaydenseric
Copy link
Author

Rad! You're doing amazing work :)

This project is saving our bacon on a last-minute Node -> PHP refactor. If I see the chance I'll try to make some contributions.

@TorbenKoehn
Copy link
Member

Official Jade can't handle #{tagName + 'def'}yzd.someItem.

Do we need it? It seems official Jade only likes #{...}-tags, without anything around it. It's easier to lex, but in reality I could do both.

What do you think?

@jaydenseric
Copy link
Author

We only need the simpler Pug implementation. More thorough interpolation from what I can tell would only enhance, not break the Pug syntax so if it's not too hard it would be nice to have.

Perhaps we could raise an issue in the Pug project and see what they think.

TorbenKoehn pushed a commit that referenced this issue May 20, 2016
@jaydenseric
Copy link
Author

It's nice to take for granted compatibility though, maybe someone will find themselves refactoring PHP Jade components back to Pug and will hit issues.

@TorbenKoehn
Copy link
Member

Too late :P

@TorbenKoehn
Copy link
Member

TorbenKoehn commented May 20, 2016

The syntax is pretty basic, but you can use abc#{$someVar}def, abc#{$someVar}, just #{$someVar} and #{$someVar}def. Inside the {}, complete expressions (should) be allowed (including function calls etc.). Just using {} inside the {} (e.g. code blocks) should fail, the regex is too basic for that :)

I will make another re-release, so clear your composer-cache and delete the vendor directory, then update again (in like 10 minutes!)

@TorbenKoehn
Copy link
Member

Also, Tale Jade contains many features that are not compatible to Node.js Jade, just the other way around is compatible :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants