-
Notifications
You must be signed in to change notification settings - Fork 38
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
A problem with string interpolation in HTML attributes #48
Comments
Glad it's helping! I'll see what I can do to get this fixed. This was reported in issue #44 but I was trying to fix it as part of a major overhaul. I don't think it can wait so I'll see about getting a fix out sooner. |
Thanks @nurugger07 👍 |
interesting. I also have a problem with this, but a different one:
produces
Is there any workaround? |
Issue #45 is quite similar to this and they have a okeish workaround - css_path = static_path(@conn, "/css/app.css")
%link{rel: "stylesheet" href: css_path} |
bump!
|
Having problems with this too |
Another workaround is to use iex(1)> Calliope.Render.precompile ~s(%a{href: 'http://<%= "www.google.com" %>'}= title)
"<a href='http://<%= \"www.google.com\" %>'><%= title %></a>\n" But it doesnt always work 😞 iex(2)> Calliope.Render.precompile ~s{%link(rel: "stylesheet" href: "<%= static_path(@conn, "/css/app.css") %>")}
"<link rel=\"stylesheet\" href=\"<%= static_path(@conn \"/css/app.css\") %>\">\n" Notice the missing |
@dcarneiro The actual workaround from #45 invloves doing interpolation: |
I started working on a fix for this issue a while ago. Will try to finish it soon. As mentioned above, set a local variable on the line above, then use that variable for the attribute without string interpolation. |
Fixed |
This is still broken @smpallen99. The tests in PR #60 are not passing on master branch. I tried it myself with this snippet: %a{href: sessions_path(@conn, :create), method: "post"} Sign In I got a compile error:
Note that I'm specifying a local copy of Calliope master branch in my local copy of phoenix-haml which is specified in my Phoenix app :) |
It should work with string interpolation. Try
I'll see if I can remove the string interpolation when I do the fix for #52. |
Is there any current work to make this project use leex and/or yecc? It seems that would make this a much more stable project... |
I'm going through the phoenix book. This doesn't seem to be working:
The following works, but it also makes an empty bootstrap alert box visible:
|
@jamesnolanverran The problem might be that your mixing attribute types. You should use either one of these:
I'm not saying that will fix the issue, but it might. I've also noticed issues with
This does not happen all the time. I remember the exact patterns when when it breaks. |
Hi perfect thanks - I switched to using |
I find the I spent a better part of a day a week ago working on the parse. got a few things fixed and broke others. This was when I was trying to fix the broke stuff in 0.4.2. I gave up and rolled back, to 0.4.1. I wish I had the time to get the tokenizer and parse working better, but I'm swamped with my Coherence and ExAdmin projects right now. |
Ah, I see I was using curly brackets with the equals sign instead of parentheses. Another minor issue - surrounding html text in parenthesis:
Workarounds:
or
|
@jamesnolanverran Would be great if you add issues for these parsing issues. I want to make sure we are tracking them. Having them buried in comments will be easy to miss :) Another option that I believe works:
|
A statement like this
produces this
while we expect the result should be similar to EEx like this
Could you help?
BTW, Thank you very much for this excellent library. It helps us (and many others) switch from Ruby to Elixir easier. 😄
The text was updated successfully, but these errors were encountered: