@FGM If the template returns a StringableInterface
<https://github.com/Dhii/stringable-interface/blob/master/src/StringableInterface.php>,
as Xedin suggested, then you can create your own return type that is
standards-compliant and also contains other information.
<?php
interface MetaDataRenderInterface extends Dhii\Util\String\
StringableInterface
{
public function getMetaData(); // Or whatever else you require
}
Your consuming code can check if the returned stringable result is an
instance of `MetaDataRenderResult` and if so, process meta data.
The reason why we (Dhii) use `StringableInterface` is because it allows us
to keep the API simple, while allowing us to use objects when we need more
information. In fact, with our current dhii/output-renderer-interface
<https://github.com/Dhii/output-renderer-interface/> package, it is
possible to have a renderer return another renderer in the form of a
BlockInterface
<https://github.com/Dhii/output-renderer-interface/blob/master/src/BlockInterface.php>,
and the consuming code would never know because it only deals with string
or string-like results.
On Monday, 25 September 2017 11:48:24 UTC+2, FGM wrote:
>
> Something else could be missing: metadata attached to the rendered result,
> like caching tags, contexts, which need to be gathered when assembling
> render results to build an actual HTTP response (coming from a Drupal
> "render array" background, as some can guess).
>
> 2017-09-25 8:21 GMT+02:00 Xedin Unknown <[email protected] <javascript:>
> >:
>
>> I believe that's a great argument for not including the template *source*
>> in the description. A template instance can encapsulate `vsprintf()`, for
>> example, and there's never going to be a file or a path resolution. This is
>> all implementation detail that can be handled via IoC.
>>
>> $template = new PrintfTemplate('Hello, %1$s!');
>> $context = new DataObject(['Xedin']);
>> $greeting = $template->render($context); // Hello, Xedin!
>>
>>
>>
>> On Monday, September 25, 2017 at 8:15:27 AM UTC+2, Nicolas Grekas wrote:
>>>
>>> > Granted, the majority of template engines use a template file-name and
>>> a set of name/value pairs
>>>
>>> Twig also doesn't reference templates by file name.
>>> It references them by logical name instead, and uses loaders to resolve
>>> that to whatever storage you'd like to use for the template strings.
>>>
>>> --
>> You received this message because you are subscribed to the Google Groups
>> "PHP Framework Interoperability Group" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/php-fig/c9192cc6-281e-44e7-98cc-ba2b5c1683c7%40googlegroups.com
>>
>> <https://groups.google.com/d/msgid/php-fig/c9192cc6-281e-44e7-98cc-ba2b5c1683c7%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
You received this message because you are subscribed to the Google Groups "PHP
Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/php-fig/2b5dc383-a7a2-4f7a-ade8-46fdf8a3a1c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.