smoothie
smoothie copied to clipboard
Unused variable warnings
Using <%=
results in unused variable warnings. 2.0.5 fixed issues with characters being escaped improperly, but currently are only good for passing through template params.
I would like to have absolute urls for my images and I would do that like this: <%= MyApp.Router.Helpers.static_url(MyApp.Endpoint, ~s(/images/img.png)) %>
This works as expected, but I can't do this because it emits a warning that this is an unused variable.
A possible fix for this would be, instead of pulling out everything between <%=
as a variable only extracting @...
. This is how eex templates work in the first place.
Great point @nsimonson, my first implementation was indeed a hacky way of pulling out and setting the variables in the EEX templates. I have a new version that is more in line with other EEX templates. The bad news is that it is a breaking change. The template functions will receive a keyword list of assigns, but this also means that the variables need a leading "@" in the templates.
I suspect that might fix the issues I've been having. I will try your branch.
@brandonparsons: Did you try the branch? Let me know if it works for you, and I will prepare to release a new major version of the lib.
@jfrolich I did try, but was having issues that I think was unrelated to this particular problem. Swapped over to just using my own EEX templates, and will inline using a different tool.
Thanks anyway!
I hope to test this over the next 2 weeks. Can you leave the issue open for a bit, I'll post back how I get on. 👍
We should just create a simple test for this. I put it on the TODO list.