Closed jonricaurte closed 8 years ago
@jonricaurte The npm page for (server-side) Jade describes the following API:
var jade = require('jade');
// compile
var fn = jade.compile('string of jade', options);
var html = fn(locals);
The jade plugin follows a similar convention. In order to allow bundling jade templates without having to bundle the jade compiler, the plugin invokes the compiler, wraps the resulting javascript function and returns it to the jspm bundler.
So the browser usage is then:
var fn = require('file.jade');
var html = fn(locals);
or
import fn from 'file.jade';
let html = fn(locals);
Note that this usage allows parameters to be passed to the jade template.
I am uncomfortable changing the standard usage, particularly using a jspm configuration setting.
I propose adding named exports fn and html. Usage:
import { html } from 'component.jade'
This would also work:
import fn from 'component.jade'
let template = fn()
and this:
import { fn } from 'component.jade'
let template = fn()
@jonricaurte What do you think?
Sounds good to me. Thanks!
In my code I always have to call the function for every import I do of a jade file; it would be nice to have an option to pass plugin-jade where it returns the already called function. An Angular 2 example is:
It would be nice if I just had to do this:
Without the parens for every template I import. Maybe have an option in the jspm config for this.
Thanks.