Skip to content

Instantly share code, notes, and snippets.

@maiha
Created October 20, 2009 20:29
Show Gist options
  • Save maiha/214586 to your computer and use it in GitHub Desktop.
Save maiha/214586 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