Coffeescript and Rendering SVG in an If condition -
i'm trying create battery checker application interprets coffeescript. i'm new coffeescript , googling didn't help.
below code tried:
if charge <= 100 render: ->""" <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewbox="0 0 24 24"> <path d="m0 0h24v24h-24z" fill="none"/> <path d="m7 17v3.67c0 .73.6 1.33 1.33 1.33h7.33c.74 0 1.34-.6 1.34-1.33v-3.67h-10z"/> <path fill-opacity=".3" d="m17 5.33c0-.73-.6-1.33-1.33-1.33h-1.67v-2h-4v2h-1.67c-.73 0-1.33.6-1.33 1.33v11.67h10v-11.67z"/> </svg> """
charge filled batterypercentage. if try render svg outside of if condition works, sadly not if.
thanks in advance!
here code compile in coffescript.org's console :
if (charge <= 100) { ({ render: function() { return "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewbox=\"0 0 24 24\">\n <path d=\"m0 0h24v24h-24z\" fill=\"none\"/>\n <path d=\"m7 17v3.67c0 .73.6 1.33 1.33 1.33h7.33c.74 0 1.34-.6 1.34-1.33v-3.67h-10z\"/>\n <path fill-opacity=\".3\" d=\"m17 5.33c0-.73-.6-1.33-1.33-1.33h-1.67v-2h-4v2h-1.67c-.73 0-1.33.6-1.33 1.33v11.67h10v-11.67z\"/>\n</svg>"; } }); }
which nothing.
you should consider removing :
after render
.
Comments
Post a Comment