Dynamiczne szablony - Liquid Markup

Dynamiczne szablony - Liquid Markup

Krzysztof Wawer

March 18, 2014

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

8 slides
  1. Własne filtry module TextFilter def textilize(input) RedCloth.new(input).to_html end end !

    Liquid::Template.register_filter(TextFilter) ! Liquid::Template.parse(" {{ '*hi*' | textilize }} "). render({}, filters: [TextFilter]) # => "<strong>hi</strong>"
  2. Liquid Tag class ExampleTag < Liquid::Tag def initialize(name, markup, token)

    ! end ! def render(context) end end ! Liquid::Template.register_tag('example_menu', ExampleTag) ! Liquid::Template.parse("{% example_tag key1=value1%}").render
  3. Liquid Drop class PostDrop < Liquid::Drop def initialize(post) @post =

    post end ! def title @post.title end end Liquid::Template.parse(„{{post.title}}, {{post.content}}”). render({ 'post' => PostDrop.new(Post.find(id)) }) => "Post title, "

More Decks by Krzysztof Wawer

Other Decks in Programming