Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Builtin example handlers #12

Closed
12 tasks done
thunderer opened this issue Aug 13, 2015 · 1 comment
Closed
12 tasks done

Builtin example handlers #12

thunderer opened this issue Aug 13, 2015 · 1 comment
Assignees
Labels
Milestone

Comments

@thunderer
Copy link
Owner

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.
@thunderer thunderer changed the title Example handlers Builtin example handlers Aug 13, 2015
@thunderer thunderer added this to the 1.1 milestone Aug 26, 2015
@thunderer thunderer self-assigned this Aug 26, 2015
@thunderer thunderer modified the milestones: 0.6, 1.1 Jan 27, 2016
@thunderer
Copy link
Owner Author

All handlers were implemented, #33 was merged, I'm closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant