Introducción

[~/sinatra/sinatra-documentation(master)]$ jekyll --help
  NAME:

    jekyll

  DESCRIPTION:

    Jekyll is a blog-aware, static site generator in Ruby

  COMMANDS:
        
    build                Build your site                
    default                             
    docs                 Launch local server with docs for Jekyll v1.1.2                
    doctor               Search site and print specific deprecation warnings            
    help                 Display global or [command] help documentation.                        
    import               Import your old blog to Jekyll         
    new                  Creates a new Jekyll site scaffold in PATH             
    serve                Serve your site locally                

  ALIASES:
  
    hyde                 doctor   
    server               serve   

  GLOBAL OPTIONS:
        
    -s, --source [DIR] 
        Source directory (defaults to ./)
        
    -d, --destination [DIR] 
        Destination directory (defaults to ./_site)
        
    --safe

Véase: Tutoriales y Documentación

  1. Jekyll: Sites Made Simple by Simon Pascal Klein SitePoint Jekyll documentation
  2. Learning Jekyll By Example: Build a Jekyll Website, Start to Finish
  3. Blogging With Jekyll And Latex
  4. Jekyll Blogging Oct 24, 2011 Cecil Woebker
  5. Intro to Jekyll por Johan Ronsse, YouTube
  6. Jekyll Static Site Generator RubyOnRailsPhoenix YouTube
  7. Hosting a static (Jekyll) blog on Amazon S3 Posted on 01 Feb 2013

Comentarios y Botones de Compartir

Plugins

Liquid

Liquid is a ruby library for rendering safe templates which cannot affect the security of the server they are rendered on. Liquid does NOT allow ruby code inside the markup.

[1] pry(main)> require 'liquid'
=> true
[2] pry(main)> @template = Liquid::Template.parse("hi {{name}}") 
=> #<Liquid::Template:0x007f820f8206e8
 @root=
  #<Liquid::Document:0x007f820f8205a8
   @nodelist=
    ["hi ",
     #<Liquid::Variable:0x007f820f8203a0
      @filters=[],
      @markup="name",
      @name="name">]>>
[3] pry(main)> @template.render('name' => 'tobi')
=> "hi tobi"

Filters can be applied on output tags:

[~/rubytesting/liquid]$ cat filters.rb 
require 'liquid'

template = <<-'EOT'
  Hello {{ 'tobi' | upcase }}
  Hello 'tobi' has {{ 'tobi' | size }} letters!
  Today is {{ 'now' | date: "%A %dth of %B %Y" }}
EOT

@template = Liquid::Template.parse(template)

puts @template.render()
[~/rubytesting/liquid]$ ruby filters.rb 
  Hello TOBI
  Hello 'tobi' has 4 letters!
  Today is Saturday 11th of January 2014

You can’t give access to objects of arbitrary classes to end users. Due security concerns, only String, Numeric, Hash, Array, Proc, Boolean or Liquid::Drop are allowed by default. The final value rendered in the template is the result of sending to_liquid message to the resolved object. Liquid extends some of the ruby standard classes with that method.

[~/rubytesting/liquid]$ cat if.rb
require 'liquid'

User = Struct.new(:name)
user = User.new('Juana')
def user.to_liquid
  {
    'name' => self.name,
    'age'  => 9
  } 
end

template = <<-'EOT'
  {% if user %}
    Hello {{ user.name}} is {{user.age}} years old
  {% endif %}
EOT

@template = Liquid::Template.parse(template)
puts @template.render("user" => user)

[~/rubytesting/liquid]$ ruby if.rb 
  
    Hello Juana is 9 years old

Creating filters is very easy. Basically, they are just methods which take one parameter and return a modified string. You can use your own filters by passing an array of modules to the render call like this: @template.render(assigns, [MyTextFilters, MyDateFilters]).

Alternatively, you can register your filters globally:

[~/rubytesting/liquid]$ cat create_filter.rb 
require 'liquid'
require 'redcloth'

module TextFilter
  def textilize input
    RedCloth.new(input).to_html
  end
end

Liquid::Template.register_filter(TextFilter)

t = <<"EOI"
{{ 'Do not *ever* pull this _lever_.' | textilize}}
EOI
template = Liquid::Template.parse t
puts template.render()

[~/rubytesting/liquid]$ ruby create_filter.rb 
<p>Do not <strong>ever</strong> pull this <em>lever</em>.</p>
[~/rubytesting/liquid]$



Subsecciones
Casiano Rodriguez León 2015-01-07