migrs (owner)

Fork Of

Revisions

gist: 214684 Download_button fork
public
Public Clone URL: git://gist.github.com/214684.git
Embed All Files: show embed
inline_filter.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
module Inline
  include Haml::Filters::Base
 
  def self.[](key)
    @@data[key.to_s] rescue nil
  end
 
  def render(str)
    @@data = Hash[*str.split(/^\s*@@\s*(\w+)\s*\n/m)[1..-1]]
    return nil
  end
end
 
input.haml #
1
2
3
4
5
6
7
8
9
10
11
12
%h1 Inline Filter
.describe= Inline[:describe]
.author created by #{Inline[:author]}
 
:inline
 @@ describe
 This filter easily separates structure and data.
 You can use in-file-templates like sinatra.
 
 @@ author
 maiha@wota.jp
 
output.html #
1
2
3
4
5
6
7
<h1>Inline Filter</h1>
<div class='describe'>
  This filter easily separates structure and data.
  You can use in-file-templates like sinatra.
</div>
<div class='author'>created by maiha@wota.jp</div>