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
For convenience and reducing the amount of code needed to be written by end user, this project should include some handlers ready to use or with minimal configuration. Since handling of raw closures would be difficult, those handlers should be made using __invoke() magic method. Several examples to work on:
RawHandler always returns getTextContent() to provide "raw" shortcode handler,
WrapHandler($before, $after) returns shortcode content with $before and $after added in respective places,
NameHandler() returns shortcode name,
DeclareHandler() allows using constructs like [declare age value=18]Your age is %value%.[/declare] and then automatically handle constructs like [age], [age value=20] and so on by adding handler to processor which replaces all parameters into content placeholders with honoring default values from declare,
ContentHandler() return shortcode content,
UrlHandler() converts shortcode content to an url,
EmailHandler() converts shortcode content to a clickable email mailto: link,
CallbackHandler($callback) passes ShortcodeInterface to given callback and returns its result (but you can pass the callback directly, so it's somewhat useless),
PlaceholderHandler() replaces %placeholders% using shortcode arguments inside its content,
EmbedHandler($type) embeds posts from given 3rd party website like Facebook, Twitter, YouTube and so on,
NullHandler() default handler usable when you want to discard a shortcode or provide default handler to Processor,
SerializerHandler(SerializerInterface $serializer) returns serialized version of passed shortcode.
The text was updated successfully, but these errors were encountered:
For convenience and reducing the amount of code needed to be written by end user, this project should include some handlers ready to use or with minimal configuration. Since handling of raw closures would be difficult, those handlers should be made using
__invoke()
magic method. Several examples to work on:RawHandler
always returnsgetTextContent()
to provide "raw" shortcode handler,WrapHandler($before, $after)
returns shortcode content with$before
and$after
added in respective places,NameHandler()
returns shortcode name,DeclareHandler()
allows using constructs like[declare age value=18]Your age is %value%.[/declare]
and then automatically handle constructs like[age]
,[age value=20]
and so on by adding handler to processor which replaces all parameters into content placeholders with honoring default values fromdeclare
,ContentHandler()
return shortcode content,UrlHandler()
converts shortcode content to an url,EmailHandler()
converts shortcode content to a clickable emailmailto:
link,,CallbackHandler($callback)
passesShortcodeInterface
to given callback and returns its result (but you can pass the callback directly, so it's somewhat useless)PlaceholderHandler()
replaces%placeholders%
using shortcode arguments inside its content,,EmbedHandler($type)
embeds posts from given 3rd party website like Facebook, Twitter, YouTube and so onNullHandler()
default handler usable when you want to discard a shortcode or provide default handler toProcessor
,SerializerHandler(SerializerInterface $serializer)
returns serialized version of passed shortcode.The text was updated successfully, but these errors were encountered: