Sha256: 2427c40ebb591d9f521e8fdb9c68d51f7873436ba43da8e62349150404959fa7

Contents?: true

Size: 718 Bytes

Versions: 5

Compression:

Stored size: 718 Bytes

Contents

class FabulatorFilter < TextFilter
  def filter(text)
    ## we *really* need to know the current page we're working with
    begin
      ctx = ( @@page.fabulator_context rescue Fabulator::Expr::Context.new )
      text_parser = Fabulator::Template::Parser.new
      parsed = text_parser.parse(ctx, text)
      parsed.add_default_values(ctx.with_root(ctx.root.roots['data']))
      r = parsed.to_html({ :theme => FabulatorTags.theme_for_this_page || 'coal' })
      r.gsub!(/^\s*<\?xml\s+.*?\?>/, '')
Rails.logger.info("Filter produces: [#{r}]")
      r
    rescue => e
      "Unable to parse contents: #{e}"
    end
  end

  def self.set_page(p)
    @@page = p
  end

  def self.reset_page
    @@page = nil
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
radiant-fabulator-extension-0.0.10 lib/fabulator_filter.rb
radiant-fabulator-extension-0.0.9 lib/fabulator_filter.rb
radiant-fabulator-extension-0.0.8 lib/fabulator_filter.rb
radiant-fabulator-extension-0.0.7 lib/fabulator_filter.rb
radiant-fabulator-extension-0.0.6 lib/fabulator_filter.rb