There's a couple of long-term goals here. The first is to begin sharing
Mobile code with other teams, so as to get ourselves in a position to merge
Mobile with desktop responsively -- likely a few years down the line. The
second is to get cross-team usage of common libraries, as opposed to
constantly "reinventing the wheel" in each product.
I think this is a great moment for us to begin the long road of
accomplishing both of those things. While it isn't a significant amount of
code, coming up with a way for us to have this usable cross-product is very
important. We really don't want to have to maintain this in two
repositories, and to address Timo's first concern, we also will never want
to end up in a situation where "Mobile is using version A, and Flow is
using version B". That is counterproductive.
What kind of solution could we plausibly use across both products?
--Shahyar
On Thu, Apr 10, 2014 at 12:16 PM, Jon Robson <jrobson(a)wikimedia.org> wrote:
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(a)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?