LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When...
Transcript of LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When...
![Page 1: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/1.jpg)
LIQUID MARKUPA story by Dane Harrigan
Friday, March 11, 2011
![Page 2: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/2.jpg)
I’m Dane Harrigan
Friday, March 11, 2011
![Page 3: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/3.jpg)
@daneharrigan
Friday, March 11, 2011
![Page 4: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/4.jpg)
Friday, March 11, 2011
![Page 5: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/5.jpg)
What is Liquid
Friday, March 11, 2011
![Page 6: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/6.jpg)
What is Liquid
When Should I use Liquid
Friday, March 11, 2011
![Page 7: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/7.jpg)
What is Liquid
When Should I use Liquid
How do I use Liquid
Friday, March 11, 2011
![Page 8: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/8.jpg)
What is Liquid
When Should I use Liquid
How do I use Liquid
Liquify: Liquid Simplified
Friday, March 11, 2011
![Page 9: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/9.jpg)
What is Liquid
Friday, March 11, 2011
![Page 10: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/10.jpg)
What is Liquid
•Template Language
Friday, March 11, 2011
![Page 11: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/11.jpg)
What is Liquid
•Template Language
•Written in Ruby
Friday, March 11, 2011
![Page 12: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/12.jpg)
What is Liquid
•Template Language
•Written in Ruby
•Similar to ERb
Friday, March 11, 2011
![Page 13: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/13.jpg)
What is Liquid
<%= %>
ERb Liquid
{{ }}
Friday, March 11, 2011
![Page 14: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/14.jpg)
What is Liquid
<%= %>
ERb Liquid
{{ }}
<% %> {% %}
Friday, March 11, 2011
![Page 15: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/15.jpg)
What is Liquid
<%= %>
ERb Liquid
{{ }}
<% %> {% %}
<%= helper(val) %> {{ val | helper }}
Friday, March 11, 2011
![Page 16: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/16.jpg)
What is Liquid
•Secure
Friday, March 11, 2011
![Page 17: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/17.jpg)
What is Liquid
•Secure
•Does Not Evaluate Ruby
Friday, March 11, 2011
![Page 18: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/18.jpg)
What is Liquid
•Secure
•Does Not Evaluate Ruby
•Is a Pain in The Ass to Use
Friday, March 11, 2011
![Page 19: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/19.jpg)
“Ok, so why would I use it?”
Friday, March 11, 2011
![Page 20: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/20.jpg)
When Should I use Liquid
When to use Liquid
When NOT to use Liquid
Friday, March 11, 2011
![Page 21: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/21.jpg)
1%99%
Friday, March 11, 2011
![Page 22: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/22.jpg)
“1%? Now I’m interested!”
Friday, March 11, 2011
![Page 23: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/23.jpg)
When Should I use Liquid
Friday, March 11, 2011
![Page 24: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/24.jpg)
When Should I use Liquid
When you’re sharing your view code
Friday, March 11, 2011
![Page 25: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/25.jpg)
When Should I use Liquid
When you’re sharing your view code
•Shopping Carts (Shopify)
Friday, March 11, 2011
![Page 26: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/26.jpg)
When Should I use Liquid
When you’re sharing your view code
•Shopping Carts (Shopify)
•Newsletter Services (MailChimp)
Friday, March 11, 2011
![Page 27: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/27.jpg)
When Should I use Liquid
When you’re sharing your view code
•Shopping Carts (Shopify)
•Newsletter Services (MailChimp)
•CMS (Magnetism, Mephisto, Jekyll)
Friday, March 11, 2011
![Page 28: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/28.jpg)
When Should I use Liquid
Friday, March 11, 2011
![Page 29: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/29.jpg)
When Should I use Liquid
When you need a limited feature set
Friday, March 11, 2011
![Page 30: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/30.jpg)
When Should I use Liquid
When you need a limited feature set
•Only allow access to specific objects
Friday, March 11, 2011
![Page 31: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/31.jpg)
When Should I use Liquid
When you need a limited feature set
•Only allow access to specific objects
•Specify which methods of an object can be executed
Friday, March 11, 2011
![Page 32: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/32.jpg)
When Should I use Liquid
When you need a limited feature set
•Only allow access to specific objects
•Specify which methods of an object can be executed
•Allow usage of predefined helper methods
Friday, March 11, 2011
![Page 33: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/33.jpg)
“Huh?”
Friday, March 11, 2011
![Page 34: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/34.jpg)
How do I use Liquid
Friday, March 11, 2011
![Page 35: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/35.jpg)
How do I use Liquid
•Drops (Classes, Models)
Friday, March 11, 2011
![Page 36: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/36.jpg)
How do I use Liquid
•Drops (Classes, Models)
•Filters (View Helpers)
Friday, March 11, 2011
![Page 37: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/37.jpg)
How do I use Liquid
•Drops (Classes, Models)
•Filters (View Helpers)
•Tags (Single Purpose Classes)
Friday, March 11, 2011
![Page 38: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/38.jpg)
“Show me some code already!”
Friday, March 11, 2011
![Page 39: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/39.jpg)
# person_drop.rbclass PersonDrop < Liquid::Drop def first_name "Dane" end def last_name "Harrigan" endend
Friday, March 11, 2011
![Page 40: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/40.jpg)
# app/models/person.rbclass Person < ActiveRecord::Baseliquid_methods :first_name, :last_name
end
Friday, March 11, 2011
![Page 41: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/41.jpg)
# rendering a liquid templatetemplate = Liquid::Template.parse(tmpl_code)template.render(:person => PersonDrop.new)
Friday, March 11, 2011
![Page 42: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/42.jpg)
# rendering a liquid templatetemplate = Liquid::Template.parse(tmpl_code)template.render(:person => PersonDrop.new)
Friday, March 11, 2011
![Page 43: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/43.jpg)
<body> <h1>{{ person.first_name }} {{ person.last_name }}</h1></body>
Friday, March 11, 2011
![Page 44: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/44.jpg)
“Ok, what about filters?”
Friday, March 11, 2011
![Page 45: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/45.jpg)
# my_filters.rbmodule MyFilters def greet(name) "Hello #{name}!" end def goodbye(name) "Goodbye #{name}!" endend
Friday, March 11, 2011
![Page 46: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/46.jpg)
# rendering a liquid templateLiquid::Template.register_filter MyFilters
template = Liquid::Template.parse(tmpl_code)template.render(:person => PersonDrop.new)
Friday, March 11, 2011
![Page 47: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/47.jpg)
# rendering a liquid templateLiquid::Template.register_filter MyFilters
template = Liquid::Template.parse(tmpl_code)template.render(:person => PersonDrop.new)
Friday, March 11, 2011
![Page 48: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/48.jpg)
<body> <h1>{{ person.first_name | greet }}</h1></body>
Friday, March 11, 2011
![Page 49: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/49.jpg)
“Way easy. Tags please.”
Friday, March 11, 2011
![Page 50: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/50.jpg)
<body> {% foo "bar", "cux" %} <h1>{{ person.first_name | greet }}</h1></body>
Friday, March 11, 2011
![Page 51: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/51.jpg)
<body> {% foo "bar", "cux" %} <h1>{{ person.first_name | greet }}</h1></body>
Friday, March 11, 2011
![Page 52: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/52.jpg)
# rendering a liquid templateLiquid::Template.register_tag 'foo', FooTag
template = Liquid::Template.parse(tmpl_code)template.render(:person => PersonDrop.new)
Friday, March 11, 2011
![Page 53: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/53.jpg)
# rendering a liquid templateLiquid::Template.register_tag 'foo', FooTag
template = Liquid::Template.parse(tmpl_code)template.render(:person => PersonDrop.new)
Friday, March 11, 2011
![Page 54: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/54.jpg)
# foo_tag.rbclass FooTag < Liquid::Tag def render(context) @markup # => '"bar", "cux"' context # => {'person' => PersonDrop.new}
# logic for your foo tag endend
Friday, March 11, 2011
![Page 55: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/55.jpg)
# foo_tag.rbclass FooTag < Liquid::Tag def render(context) @markup # => '"bar", "cux"' context # => {'person' => PersonDrop.new}
# logic for your foo tag endend
Friday, March 11, 2011
![Page 56: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/56.jpg)
“Ok, real example please?”
Friday, March 11, 2011
![Page 57: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/57.jpg)
<!DOCTYPE HTML><html> <body> {% snippet 'header' %} <h1>{{ person.first_name | greet }}</h1> {% snippet 'footer' %} </body></html>
Friday, March 11, 2011
![Page 58: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/58.jpg)
<!DOCTYPE HTML><html> <body> {% snippet 'header' %} <h1>{{ person.first_name | greet }}</h1> {% snippet 'footer' %} </body></html>
Friday, March 11, 2011
![Page 59: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/59.jpg)
# rendering a liquid templateLiquid::Template.register_tag 'snippet', SnippetTag
template = Liquid::Template.parse(tmpl_code)template.render(:person => PersonDrop.new)
Friday, March 11, 2011
![Page 60: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/60.jpg)
# snippet_tag.rbclass SnippetTag < Liquid::Tag def render(context) name = @markup.gsub(/("|')/,'').strip
tmpl = Template.snippets.first_by_name(name) content = tmpl.content
template = Liquid::Template.parse(content) template.render(:person => PersonDrop.new) endend
Friday, March 11, 2011
![Page 61: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/61.jpg)
# snippet_tag.rbclass SnippetTag < Liquid::Tag def render(context) name = @markup.gsub(/("|')/,'').strip
tmpl = Template.snippets.first_by_name(name) content = tmpl.content
template = Liquid::Template.parse(content) template.render(:person => PersonDrop.new) endend
Friday, March 11, 2011
![Page 62: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/62.jpg)
# snippet_tag.rbclass SnippetTag < Liquid::Tag def render(context) name = @markup.gsub(/("|')/,'').strip
tmpl = Template.snippets.first_by_name(name) content = tmpl.content
template = Liquid::Template.parse(content) template.render(:person => PersonDrop.new) endend
Friday, March 11, 2011
![Page 63: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/63.jpg)
# snippet_tag.rbclass SnippetTag < Liquid::Tag def render(context) name = @markup.gsub(/("|')/,'').strip
tmpl = Template.snippets.first_by_name(name) content = tmpl.content
template = Liquid::Template.parse(content) template.render(:person => PersonDrop.new) endend
Friday, March 11, 2011
![Page 64: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/64.jpg)
# snippet_tag.rbclass SnippetTag < Liquid::Tag def render(context) name = @markup.gsub(/("|')/,'').strip
tmpl = Template.snippets.first_by_name(name) content = tmpl.content
template = Liquid::Template.parse(content) template.render(:person => PersonDrop.new) endend
Friday, March 11, 2011
![Page 65: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/65.jpg)
# snippet_tag.rbclass SnippetTag < Liquid::Tag def render(context) name = @markup.gsub(/("|')/,'').strip
tmpl = Template.snippets.first_by_name(name) content = tmpl.content
template = Liquid::Template.parse(content) template.render(:person => PersonDrop.new) endend
Friday, March 11, 2011
![Page 66: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/66.jpg)
“Can this actually get easier?”
Friday, March 11, 2011
![Page 67: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/67.jpg)
Liquify: Liquid Simplified
Friday, March 11, 2011
![Page 68: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/68.jpg)
•Register Drops, Filters and Tags in one Place
Liquify: Liquid Simplified
Friday, March 11, 2011
![Page 69: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/69.jpg)
•Register Drops, Filters and Tags in one Place
•Improvements to liquid_methods
Liquify: Liquid Simplified
Friday, March 11, 2011
![Page 70: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/70.jpg)
•Register Drops, Filters and Tags in one Place
•Improvements to liquid_methods
•Auto-parsed Parameters
Liquify: Liquid Simplified
Friday, March 11, 2011
![Page 71: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/71.jpg)
# register tagLiquid::Template.register_tag 'foo', FooTag
# register filtersLiquid::Template.register_filter BarFilters
# register droptmpl = Liquid::Template.parse(template_code)tmpl.render(:person => PersonDrop.new)
Friday, March 11, 2011
![Page 72: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/72.jpg)
# register tagLiquid::Template.register_tag 'foo', FooTag
# register filtersLiquid::Template.register_filter BarFilters
# register droptmpl = Liquid::Template.parse(template_code)tmpl.render(:person => PersonDrop.new)
Friday, March 11, 2011
![Page 73: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/73.jpg)
# register tagLiquid::Template.register_tag 'foo', FooTag
# register filtersLiquid::Template.register_filter BarFilters
# register droptmpl = Liquid::Template.parse(template_code)tmpl.render(:person => PersonDrop.new)
Friday, March 11, 2011
![Page 74: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/74.jpg)
# register tagLiquid::Template.register_tag 'foo', FooTag
# register filtersLiquid::Template.register_filter BarFilters
# register droptmpl = Liquid::Template.parse(template_code)tmpl.render(:person => PersonDrop.new)
Friday, March 11, 2011
![Page 75: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/75.jpg)
“I’m dying to see Liquify!”
Friday, March 11, 2011
![Page 76: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/76.jpg)
Liquify.setup do |config| config.register_tag :foo, FooTag config.register_filter BarFilters config.register_drop :person, PersonDrop
# need access to stuff later? config.register_drop :person, lambda { PersonDrop.first }end
Friday, March 11, 2011
![Page 77: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/77.jpg)
Liquify.setup do |config| config.register_tag :foo, FooTag config.register_filter BarFilters config.register_drop :person, PersonDrop
# need access to stuff later? config.register_drop :person, lambda { PersonDrop.first }end
Friday, March 11, 2011
![Page 78: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/78.jpg)
Liquify.setup do |config| config.register_tag :foo, FooTag config.register_filter BarFilters config.register_drop :person, PersonDrop
# need access to stuff later? config.register_drop :person, lambda { PersonDrop.first }end
Friday, March 11, 2011
![Page 79: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/79.jpg)
Liquify.setup do |config| config.register_tag :foo, FooTag config.register_filter BarFilters config.register_drop :person, PersonDrop
# need access to stuff later? config.register_drop :person, lambda { PersonDrop.first }end
Friday, March 11, 2011
![Page 80: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/80.jpg)
Liquify.setup do |config| config.register_tag :foo, FooTag config.register_filter BarFilters config.register_drop :person, PersonDrop
# need access to stuff later? config.register_drop :person, lambda { PersonDrop.first }end
Friday, March 11, 2011
![Page 81: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/81.jpg)
Liquify.invoke(template_code)
Friday, March 11, 2011
![Page 82: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/82.jpg)
“Sweet!”
Friday, March 11, 2011
![Page 83: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/83.jpg)
class Person < ActiveRecord::Base liquify_methods :first_name, :last_name, :full_name => lambda { |p| "#{p.first_name} #{p.last_name}" }end
Friday, March 11, 2011
![Page 84: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/84.jpg)
“I approve.”
Friday, March 11, 2011
![Page 85: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/85.jpg)
<body> <h1>{{ person.first_name | greet }}</h1> {% snippet 'profile', item: person, class: 'active' %}</body>
Friday, March 11, 2011
![Page 86: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/86.jpg)
<body> <h1>{{ person.first_name | greet }}</h1> {% snippet 'profile', item: person, class: 'active' %}</body>
Friday, March 11, 2011
![Page 87: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/87.jpg)
class SnippetTag < Liquify::Tag def invoke(params) params # => ['profile', { # 'item' => PersonDrop.new, # 'class' => 'active'} # ] endend
Friday, March 11, 2011
![Page 88: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/88.jpg)
class SnippetTag < Liquify::Tag def invoke # don't need params? endend
Friday, March 11, 2011
![Page 89: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/89.jpg)
“You’ve changed my life.”
Friday, March 11, 2011
![Page 90: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/90.jpg)
I’m Dane Harrigan
Friday, March 11, 2011
![Page 91: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/91.jpg)
Thanks
Friday, March 11, 2011
![Page 92: LIQUID MARKUP - Meetupfiles.meetup.com/1397868/Liquid-Markup.pdf · When Should I use Liquid When you need a limited feature set •Only allow access to specific objects •Specify](https://reader033.fdocuments.in/reader033/viewer/2022042416/5f315b70d202696f7217025b/html5/thumbnails/92.jpg)
Twitter: @daneharrigan
Github: daneharrigan
gem install liquify
Friday, March 11, 2011