Skip to content

Conversation

@eduardosoliv
Copy link
Contributor

This makes more convenient to use the string template.

Instead of:

$engine = new StringTemplate\Engine();
$enginer->render(...);

Can be used:

EngineFactory::create()->render(...);

If you see other libs that are similar:
https://github.com/jalet/util-sprintf-php

The way of use is really simple:

Sprintf::f("My cat is %color%.", array('color' => 'brown'));

I prefer StringTemplate over that one, but I would prefer a more convenient way to use it, at least a factory.

Note: I didn't put any license on header of new files, because on code base there are 2 types of headers, so didn't know which one to use.

@nicmart
Copy link
Owner

nicmart commented Aug 15, 2014

I don't see your example as a valid reason to use a factory. Factory is a creational pattern, and should be used wisely. Direct method invocation is not a good reason to use a factory, in my opinion. Also note that in php >= 5.4 you can use direct method invocation after instantiation:

(new Engine)->render(...);

Even if I discourage it, if you need static access to Engine methods I think it is better to implement an adaptor on the client side.

@nicmart nicmart closed this Aug 15, 2014
marios88 added a commit to marios88/StringTemplate that referenced this pull request Feb 11, 2023
Passing null to parameter nicmart#2 ($replace) of type array|string is deprecated
@marios88 marios88 mentioned this pull request Feb 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants