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

Modules: Endpoint, GQL

Constant Summary collapse

VERSION =
"1.3.0"

Class Method Summary collapse

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, options, callback)
    result = ""
    if node["children"] && node["children"].length() > 0
        result = node_children_to_html(node["children"], options, 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, options)
    reference = -> (){
        result = ""
        if options.entry != nil
            object = findObject(, options.entry)
            if object!= nil && object.length() > 0 
                result = options.render_option(object[0], )
            else
                content.each do |node|
                    inner_html = json_doc_to_html(node, options, reference)
                    result =  options.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, options, reference) )
        end
        result
    elsif content.instance_of? Hash
        json_doc_to_html(content, options, 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, options)
    if (content.instance_of? Array)
        result = []
        content.each do |n|
            result.push(render_string(n, options))
        end
        result
    elsif content.instance_of? String
        render_string(content, options)
    end
end