smoothie icon indicating copy to clipboard operation
smoothie copied to clipboard

Unused variable warnings

Open nsimonson opened this issue 8 years ago • 6 comments

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.

nsimonson avatar Jan 31 '17 00:01 nsimonson

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.

jfrolich avatar Jan 31 '17 14:01 jfrolich

I suspect that might fix the issues I've been having. I will try your branch.

brandonparsons avatar Feb 01 '17 12:02 brandonparsons

@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 avatar Feb 06 '17 01:02 jfrolich

@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!

brandonparsons avatar Feb 06 '17 16:02 brandonparsons

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. 👍

stephenmoloney avatar Feb 06 '17 16:02 stephenmoloney

We should just create a simple test for this. I put it on the TODO list.

stephenmoloney avatar Mar 31 '17 20:03 stephenmoloney