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

Transphporm calculates attribute value with / in it instead of passing it as string when using data(myfunction(attr(name))) #214

Closed
mabalito opened this issue Apr 4, 2019 · 4 comments

Comments

@mabalito
Copy link

mabalito commented Apr 4, 2019

Hi,

I'm having this tss:
include { content: data(getInclude(attr(file))); content-mode: replace; format: html; }

and this xml:
<include file="path/tofile.xml"></include>

Transphporm tries to calculate the attribute (and obviously fails) instead of passing it as a string to my getInclude($file) function. Instead of the expected string "path/tofile.xml" the function receives "NAN".

If I remove "path/" the function receives "xml", so there's also some weird behaviour with attribute values with a "." in it. Weirdly, Transphporm doesn't try to calculate attribute values with a "-" in it, so it's very inconsistent.

I would expect the value to get passed as-is, i.e. as a string.

Thanks in advance

@garrettw
Copy link
Contributor

garrettw commented Apr 4, 2019

If I'm not misunderstanding, the readme indicates that you would do this with the following TSS:

include { content: template(attr(file)); content-mode: replace; format: html; }

@mabalito
Copy link
Author

mabalito commented Apr 5, 2019

Yes, that would have worked for me if it weren't for #213 and #215.

What I instead have come up with is a function that creates a new \Transphporm\Builder instance and returns the output to the "parent" view.

Also, I don't see why attr() should behave differently when it's used in data() and template(). It should be consistent in my opinion.

Btw, thanks for a great project!

@TRPB
Copy link
Member

TRPB commented Feb 2, 2020

This is treating the value as a division. Unfortunately this is the same issue as #221, and a rather large job as it will require rewriting a lot of the parser. I'm glad you've got a workaround in this instance so I'll close this for now, but keep an eye on #221 as I'll update that when I recreate the parser.

@TRPB
Copy link
Member

TRPB commented Feb 2, 2020

This should be fixed in the latest commit to master. #213 and #215 still need addressing though.

@TRPB TRPB closed this as completed Feb 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants