Closed cfjedimaster closed 5 years ago
+1 can't seem to read in javascript files for example that I would like to inline in a <script>
tags. I have tried partials (which I also learned are not supported in Jade; includes, which ignore anything with a .js
extension or most anything else for that matter. My last hope was actually using JavaScript to read in the file into a variable.
@robmuh I'm doing this with Jade to inline javascript and it works fine:
script
include ../scripts/echo.js
Well that is definitely working in 0.19 (wasn't in 0.14) and is something, but I was hoping to be able to loop through all the .js
files or all files in js
directory and include them with something like the following, which does not seem to work still:
doctype
html
body
script
- for f in public._contents
- if (f.slice(f.length-3,f.length) == '.js')
!= partial(f)
This throws no error and works if you use if for non .js
files. It still doesn't minify, etc, but at least it would be one way to automatically inline all the JavaScript without touching the Jade for every new file created.
By the way, this makes Phaser.io game development so much nicer than the alternatives.
You can loop through all files. It is in the public scope I believe. See the Cookbook as they have an example of this.
On Wed, Oct 21, 2015 at 9:26 AM, Rob Muhlestein notifications@github.com wrote:
Well that is definitely working in 0.19 (wasn't in 0.14) and is something, but I was hoping to be able to loop through all the .js files or all files in js directory and include them with something like the following, which does not seem to work still:
doctypehtml body script - for f in public._contents - if (f.slice(f.length-3,f.length) == '.js') != partial(f)
This throws no error and works if you use if for non .js files. It still doesn't minify, etc, but at least it would be one way to automatically inline all the JavaScript without touching the Jade for every new file created.
By the way, this makes Phaser.io game development so much nicer than the alternatives.
— Reply to this email directly or view it on GitHub https://github.com/sintaxi/harp/issues/499#issuecomment-149912364.
Raymond Camden, Developer Advocate for MobileFirst at IBM
Email : raymondcamden@gmail.com Blog : www.raymondcamden.com Twitter: raymondcamden
Yes this loop works perfectly and I can print the name of the file in the html, the problem seems to be with the partial, it will not load the content of the file. It is a pretty simple test if anyone would like to confirm it. Just place main.js
and blah.js
in the same public
with index.jade
to recreate.
Would it be possible to expose access to the file system, perhaps by making fs available to templates?