You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently in order to create a Snippet from partial XML (i.e list items without the ul or ol wrappers) the TempladoSnippet can be used. However it requires that the user knows to wrap the partial in code in the Templado namespace:
While I like the idea, I'm not sure where this functionality belongs.
Adding it to the TempladoSnippet sounds like a good fit at first glance. But not having a general fromString feels incomplete. That though would lead to having a fromString method on TextSnippet and SimpleSnippet as well. That in turn would lead to duplicate code as at least TempladoSnippet and SimpleSnippet need to ensure the given string translates into valid (=parsable) XML.
Adding it to the SnippetLoader feels wrong as this is not actually "loading" anything, more like mapping.
So, does that mean we should add a SnippetMapper that can translate strings into their respective best matching type of snippet? Or more like explicit map calls?
What about the idea of creating a simple wrapper class (i.e. Templado\Engine\SnippetPartial) that is instantiated with a string and internally wraps it with the namespace. Then TempladoSnippet takes that as a dependency.
Currently in order to create a Snippet from partial XML (i.e list items without the ul or ol wrappers) the TempladoSnippet can be used. However it requires that the user knows to wrap the partial in code in the Templado namespace:
A DOMNode must be created, the partial code must be wrapped, and the wrapped code then loaded into the DOMNode.
It would be a nice convenience if this process were moved under the hood. Perhaps a factory method could be added to the TempladoSnippet:
Or perhaps this code could be added to the Snippet loader.
The text was updated successfully, but these errors were encountered: