Module: ContentstackUtils
- Included in:
- GQL
- Defined in:
- lib/contentstack_utils/utils.rb,
lib/contentstack_utils/version.rb,
lib/contentstack_utils/endpoint.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
"1.3.0"
Class Method Summary collapse
- .get_contentstack_endpoint(region: 'us', service: '', omit_https: false) ⇒ Object
- .json_doc_to_html(node, options, callback) ⇒ Object
- .json_to_html(content, options) ⇒ Object
- .render_content(content, options) ⇒ Object
Class Method Details
.get_contentstack_endpoint(region: 'us', service: '', omit_https: false) ⇒ Object
140 141 142 |
# File 'lib/contentstack_utils/utils.rb', line 140 def self.get_contentstack_endpoint(region: 'us', service: '', omit_https: false) Endpoint.get_contentstack_endpoint(region: region, service: service, omit_https: omit_https) end |
.json_doc_to_html(node, options, callback) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/contentstack_utils/utils.rb', line 47 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
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 45 |
# File 'lib/contentstack_utils/utils.rb', line 20 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
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/contentstack_utils/utils.rb', line 8 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 |