Support mustache partials in server-side templates
This is sufficient to make https://gerrit.wikimedia.org/r/#/c/223165/ work. It hardcodes .mustache as the extension, but so does existing getTemplateFilename(). Bug: T97188 Change-Id: Id588ae9b43b13fcf35ebd285c826dd502ac424ec
This commit is contained in:
parent
240f4c15d5
commit
c235e0717e
4 changed files with 19 additions and 2 deletions
|
|
@ -173,7 +173,9 @@ class TemplateParser {
|
|||
array(
|
||||
// Do not add more flags here without discussion.
|
||||
// If you do add more flags, be sure to update unit tests as well.
|
||||
'flags' => LightnCandy::FLAG_ERROR_EXCEPTION
|
||||
'flags' => LightnCandy::FLAG_ERROR_EXCEPTION,
|
||||
'basedir' => $this->templateDir,
|
||||
'fileext' => '.mustache',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
1
tests/phpunit/data/templates/bad_partial.mustache
Normal file
1
tests/phpunit/data/templates/bad_partial.mustache
Normal file
|
|
@ -0,0 +1 @@
|
|||
Partial {{>nonexistenttemplate}} in here
|
||||
1
tests/phpunit/data/templates/has_partial.mustache
Normal file
1
tests/phpunit/data/templates/has_partial.mustache
Normal file
|
|
@ -0,0 +1 @@
|
|||
Partial {{>foobar_args}} in here
|
||||
|
|
@ -57,7 +57,20 @@ class TemplateParserTest extends MediaWikiTestCase {
|
|||
array(),
|
||||
false,
|
||||
'RuntimeException',
|
||||
)
|
||||
),
|
||||
array(
|
||||
'has_partial',
|
||||
array(
|
||||
'planet' => 'world',
|
||||
),
|
||||
"Partial hello world!\n in here\n",
|
||||
),
|
||||
array(
|
||||
'bad_partial',
|
||||
array(),
|
||||
false,
|
||||
'Exception',
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue