module Fluid::Textable
Overview
The Fluid::Textable
mixin automatically generates methods to generate text output of a report. As text documents have no special formatting, it's the simplest Fluid
mixin.
A simple example:
require "fluid"
class TextGreeting
include Fluid::Textable
@@text_template_source = "Hello {{name}}"
def initialize(@name : String)
end
end
greeting = TextGreeting.new("World!")
greeting.to_text #=> "Hello World!"
The #to_text
returns a String generated from the Liquid template provided. The Context
for this generation automatically includes all instance variables by their own name, without the '@' sign in front. The method also calls the #before_render
and #before_to_text
hooks after adding the instance variables to the context, allowing the developer to overwrite any of them, or add additional values to the context.
Defined in:
fluid/textable.crInstance Method Summary
-
#before_render
A hook that is executed during the output of any
Fluid
mixin. -
#before_to_text
A hook that is executing during the
#to_text
method. -
#to_text : String
Generates and returns the text output of the document.
Instance Method Detail
A hook that is executed during the output of any Fluid
mixin. Unlike '#before_to_text', this hook is called during all Fluid
mixin output methods.
Generates and returns the text output of the document.
Executes 2 hooks, #before_render
and #before_to_text
, in that order.