I have figured out a way to do this, defining a variable inside a HTML attribute like this:
div data-name=some_var id="component"
Then from Javascript I can retrieve it:
alert($("#component").data("name"));
However, it looks very ugly to me. Is there another way to achieve this?