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

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, 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



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, 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



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/contentstack_utils/utils.rb', line 7

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