Skip to content

Instantly share code, notes, and snippets.

@migrs
Forked from maiha/inline_filter.rb
Created October 20, 2009 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save migrs/214684 to your computer and use it in GitHub Desktop.
Save migrs/214684 to your computer and use it in GitHub Desktop.
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
%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
<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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment