ladjs / express-cdn

:cloud: Node module for delivering optimized, minified, mangled, gzipped assets with Express and Amazon's CDN (S3/CloudFront)
MIT License
660 stars 104 forks source link

Working with html + swig? #79

Open gonzalodiaz opened 9 years ago

gonzalodiaz commented 9 years ago

Is this library able to work with html + swig instead of jade or ejs?

I had this code:

{% for cssFile in cssFiles %}<link rel="stylesheet" href="{{cssFile}}">
{% endfor %}

where cssFiles it is the list of Css Files stored as String in a config file.

I've change it to this:

    {% for cssFile in cssFiles %}
      <script type="text/javascript">
          var cssFileVal = "{{cssFile}}";
                  {{ CDN(cssFileVal) }}
      </script>
    {% endfor %}

But the code in {{}} is not pre processed, so I end having this:

{ "assets": cssFileVal }
                 ^
SyntaxError: Unexpected token c

I will really appreciate some help to make this work. Thanks

tsestrich commented 8 years ago

This was a long time ago, but I wanted to comment that I do use SWIG with this just fine. Without running the code above, it looks like its a mistake in the code itself. It should be something like:

{% for cssFile in cssFiles %}
      {{ CDN(cssFileVal) }}
{% endfor %}