Kelly Martin changelog.com/posts

Add WordPress-style shortcodes to your Ruby blog

One of WordPress’s strengths is the ability to give non-coders a way to generate custom data with the use of shortcodes. Shortcode elegantly brings that classic feature to the Ruby community.

The gem notes using Parsing expression grammar instead of regular expressions to improve the readability and testability of the code. It supports both block tags and self-closing tags, and adding shortcodes is as easy as adding a partial.

%blockquote
  %p.quotation= @content
  - if @attributes[:author]
    %span.author= @attributes[:author]

Shortcode also supports custom presenters for more complex tasks like image galleries. Take a look at the documentation on GitHub.


Discussion

Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00