Module: ContentstackUtils
- Included in:
- GQL
- Defined in:
- lib/contentstack_utils/utils.rb,
lib/contentstack_utils/version.rb
Defined Under Namespace
Modules: GQL
Constant Summary collapse
- VERSION =
"1.2.1"
Class Method Summary collapse
- .json_doc_to_html(node, options, callback) ⇒ Object
- .json_to_html(content, options) ⇒ Object
- .render_content(content, options) ⇒ Object
Class Method Details
.json_doc_to_html(node, options, callback) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/contentstack_utils/utils.rb', line 46 def self.json_doc_to_html(node, , callback) result = "" if node["children"] && node["children"].length() > 0 result = node_children_to_html(node["children"], , callback) end result end |
.json_to_html(content, options) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/contentstack_utils/utils.rb', line 19 def self.json_to_html(content, ) reference = -> (){ result = "" if .entry != nil object = findObject(, .entry) if object!= nil && object.length() > 0 result = .render_option(object[0], ) else content.each do |node| inner_html = json_doc_to_html(node, , reference) result = .render_node(node["type"], node, inner_html) end end end result } if (content.instance_of? Array) result = [] content.each do |n| result.push(json_doc_to_html(n, , reference) ) end result elsif content.instance_of? Hash json_doc_to_html(content, , reference) end end |
.render_content(content, options) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/contentstack_utils/utils.rb', line 7 def self.render_content(content, ) if (content.instance_of? Array) result = [] content.each do |n| result.push(render_string(n, )) end result elsif content.instance_of? String render_string(content, ) end end |