Module: Quby::TextTransformation
- Defined in:
- lib/quby/text_transformation.rb
Constant Summary collapse
- LINK_URL_REGEX =
Modal pop up window link: ~~url~~link_body~~
/\~\~(?<url>.+?)\~\~(?<link_content>.+?)\~\~/
- TEXT_VAR_REGEX =
Textvars: Replace {var_name} with <span class=‘textvar’ textvar=‘var_name’></span>
/\{\{(?<text_var>.+?)\}\}/
Instance Method Summary collapse
- #link_html(url, link_content) ⇒ Object
- #textvar_html(var_name) ⇒ Object
-
#transform_special_text(text) ⇒ Object
to eventually replace maruku_extensions.rb this helper transforms ~~ links and vars} into html.
Instance Method Details
#link_html(url, link_content) ⇒ Object
18 19 20 |
# File 'lib/quby/text_transformation.rb', line 18 def link_html(url, link_content) "<a href='#' onclick='modalFrame(\"#{url}\");'>#{link_content}</a>" end |
#textvar_html(var_name) ⇒ Object
22 23 24 |
# File 'lib/quby/text_transformation.rb', line 22 def textvar_html(var_name) "<span class='textvar' textvar='#{var_name}'>{{#{var_name}}}</span>" end |
#transform_special_text(text) ⇒ Object
to eventually replace maruku_extensions.rb this helper transforms ~~ links and vars} into html
13 14 15 16 |
# File 'lib/quby/text_transformation.rb', line 13 def transform_special_text(text) text.gsub(LINK_URL_REGEX) { link_html($~[:url], $~[:link_content]) } .gsub(TEXT_VAR_REGEX) { textvar_html($~[:text_var]) } end |