Skip to content

Commit

Permalink
Support markdown filter via tilt
Browse files Browse the repository at this point in the history
  • Loading branch information
eagletmt committed Mar 18, 2015
1 parent 4ca6a17 commit bbbaf92
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions fast_haml.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "haml"
spec.add_development_dependency "rake"
spec.add_development_dependency "rake-compiler"
spec.add_development_dependency "redcarpet"
spec.add_development_dependency "rspec", ">= 3"
spec.add_development_dependency "sass"
spec.add_development_dependency "simplecov"
Expand Down
1 change: 1 addition & 0 deletions lib/fast_haml/filter_compilers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def self.find(name)
require 'fast_haml/filter_compilers/css'
require 'fast_haml/filter_compilers/escaped'
require 'fast_haml/filter_compilers/javascript'
require 'fast_haml/filter_compilers/markdown'
require 'fast_haml/filter_compilers/plain'
require 'fast_haml/filter_compilers/preserve'
require 'fast_haml/filter_compilers/ruby'
Expand Down
18 changes: 18 additions & 0 deletions lib/fast_haml/filter_compilers/markdown.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require 'fast_haml/filter_compilers/tilt_base'

module FastHaml
module FilterCompilers
class Markdown < TiltBase
def need_newline?
false
end

def compile(texts)
temple = [:multi, [:newline]]
compile_with_tilt(temple, 'markdown', texts)
end
end

register(:markdown, Markdown)
end
end
19 changes: 19 additions & 0 deletions spec/render/filters/markdown_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'spec_helper'

RSpec.describe 'Markdown filter rendering', type: :render do
it 'renders Markdown filter' do
expect(render_string(<<HAML)).to eq("<h1>hello</h1>\nworld\n")
:markdown
# hello
world
HAML
end

it 'parses string interpolation' do
expect(render_string(<<'HAML')).to eq("<h1>hello</h1>\nworld\n")
:markdown
# #{'hello'}
world
HAML
end
end

0 comments on commit bbbaf92

Please sign in to comment.