Merged
Conversation
Instead of throwing an exception when load() is called, an Input instance is returned. Its exists() method can be used to test whether the loaded template exists. See xp-forge/handlebars#9 (review)
thekid
commented
Sep 17, 2017
| * @return string The rendered output | ||
| */ | ||
| public function render($template, $arg, $start= '{{', $end= '}}', $indent= '') { | ||
| if ($template instanceof Template) { |
Member
Author
There was a problem hiding this comment.
This was dropped, use evaluate() if necessary.
thekid
commented
Sep 17, 2017
| * @test xp://com.github.mustache.unittest.FileBasedTemplateLoaderTest | ||
| */ | ||
| abstract class FileBasedTemplateLoader implements TemplateLoader, WithListing { | ||
| abstract class FileBasedTemplateLoader implements Templates, WithListing { |
Member
Author
There was a problem hiding this comment.
The WithListing interface should be merged into the Templates class.
Member
Author
|
This is unfortunately not backwards compatible as the template loaders have changed type, and passing them to a method with type hint yields: Argument 1 passed to com\handlebarsjs\HandlebarsEngine::withTemplates() must be an instance of com\github\mustache\TemplateLoader, instance of com\github\mustache\InMemory given |
thekid
commented
Sep 17, 2017
| if ($source instanceof Source) { | ||
| return $source->compile($this->parser, $start, $end, $indent); | ||
| } else { | ||
| return new Template('<string>', $this->parser->parse(new StringTokenizer($source), $start, $end, $indent)); |
Member
Author
There was a problem hiding this comment.
This could also be:
$source= new Tokens('<string>', new StringTokenizer($source));
return $source->compile($this->parser, $start, $end, $indent); ...but the inlined version saves us a couple of nanoseconds here:)
Member
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Instead of throwing an exception when load() is called, an Input instance is returned. Its exists() method can be used to test whether the loaded template exists.
Old code
Needs to use exceptions for flow control...
New code
Longer but can use exists() to check for templates
See xp-forge/handlebars#9 (review)