mw.template = {
add: function(name, engineName){
// used by RL
},
get: function(name) {
if ( this.isCompiledTemplate( name ) ) {
return this._compileTemplate( name );
} else {
return this._compiledTemplates[name];
}
}
}
mw.template.addEngine( 'Hogan', {
compile: function( templateBody ) {Hogan.compile( templateBody ); }
} );
$wgResourceModule['myfoo'] = array( 'dependencies' => array(
'mediawiki.template',
'mediawiki.templates.knockoff', 'mediawiki.templates.hogan' ),
'templates' => array( 'templates/foo.hogan', 'templates/foo.knockoff'
)
I was imagining something like the above - a template system which in
theory could support multiple template languages. The end result
should be a MediaWiki instance which can be configured by the owner to
choose their preferred template language or support multiple template
languages.
Wikimedia instances / core should only promote/use __one__ of these
template languages but our code should be generic and flexible enough.
The LESS implementation was done in such a generic way that SASS could
be used instead (I have an outstanding TODO with the Wikia guys to
help make this happen). Our template system should be no different.
On Wed, Apr 9, 2014 at 5:49 PM, Matthew Walker <mwalker@wikimedia.org> wrote:
>> 2) All it would provide is "template.add( key, htmlString )" and
>> "template.get( key )" returning said htmlString, it wouldn't invoke the
>> template engine because that's not yet shared. Also at this time,
>> MobileFrontend's version defines this add/get interface as "mw.template"
>> which seems too generic (should probably be mw.mobileFrontend.template or
>> mw.mfTemplate).
>
>
> Agreed on this point. I know that Gabriel and I's solution is not quite
> ready and no one is using it yet; but we're going to need a custom RL module
> anyways at some point down the line. Our templates get compiled into an
> intermediate form which RL will deliver -- so it'll eventually have a LESS
> style pipeline.
>
> In any case, my solution's templates will not be compatible with your
> templates. So; perhaps mw.mustacheTemplate.get or something?