Class: Msgtrail::PartialRenderer
- Inherits:
-
Object
- Object
- Msgtrail::PartialRenderer
- Includes:
- RenderHelper
- Defined in:
- lib/msgtrail/renderers.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#markdown ⇒ Object
Returns the value of attribute markdown.
-
#partial ⇒ Object
Returns the value of attribute partial.
-
#plaintext ⇒ Object
Returns the value of attribute plaintext.
-
#variables ⇒ Object
Returns the value of attribute variables.
Instance Method Summary collapse
-
#initialize(partial_filepath, variables, config) ⇒ PartialRenderer
constructor
A new instance of PartialRenderer.
- #method_missing(missing_method_name, *args, &block) ⇒ Object
- #render ⇒ Object
Methods included from RenderHelper
#as_rfc3339, #now_as_rfc3339, #titlecase, #xml_safe
Constructor Details
#initialize(partial_filepath, variables, config) ⇒ PartialRenderer
Returns a new instance of PartialRenderer.
95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/msgtrail/renderers.rb', line 95 def initialize(partial_filepath, variables, config) begin self.partial = File.read(partial_filepath) rescue puts("Can't find '#{partial_filepath}' (#{$!})") exit(2) end self.config = config self.markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, fenced_code_blocks: true, strikethrough: true) self.plaintext = Redcarpet::Markdown.new(Redcarpet::Render::StripDown) self.variables = variables end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(missing_method_name, *args, &block) ⇒ Object
108 109 110 111 112 113 114 |
# File 'lib/msgtrail/renderers.rb', line 108 def method_missing(missing_method_name, *args, &block) if 'cfg' == missing_method_name.to_s self.config.settings else super end end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
93 94 95 |
# File 'lib/msgtrail/renderers.rb', line 93 def config @config end |
#markdown ⇒ Object
Returns the value of attribute markdown.
93 94 95 |
# File 'lib/msgtrail/renderers.rb', line 93 def markdown @markdown end |
#partial ⇒ Object
Returns the value of attribute partial.
93 94 95 |
# File 'lib/msgtrail/renderers.rb', line 93 def partial @partial end |
#plaintext ⇒ Object
Returns the value of attribute plaintext.
93 94 95 |
# File 'lib/msgtrail/renderers.rb', line 93 def plaintext @plaintext end |
#variables ⇒ Object
Returns the value of attribute variables.
93 94 95 |
# File 'lib/msgtrail/renderers.rb', line 93 def variables @variables end |
Instance Method Details
#render ⇒ Object
116 117 118 |
# File 'lib/msgtrail/renderers.rb', line 116 def render ERB.new(self.partial).result(binding) end |