diff --git a/lib/contentstack_utils/model/metadata.rb b/lib/contentstack_utils/model/metadata.rb
index 2412082..ede348c 100644
--- a/lib/contentstack_utils/model/metadata.rb
+++ b/lib/contentstack_utils/model/metadata.rb
@@ -1,7 +1,7 @@
module ContentstackUtils
module Model
- class Metadata
+ class Metadata
def initialize( element )
if element.instance_of? Nokogiri::XML::Element
@itemType = element.attribute('type') ? element.attribute('type').value : nil
@@ -16,44 +16,45 @@ def initialize( element )
@styleType = element["attrs"]['display-type']
@itemUid ||= element["attrs"]['entry-uid'] || element["attrs"]['asset-uid']
@contentTypeUid = element["attrs"]['content-type-uid']
- if element["children"] && element["children"].length() > 0
+ if element["children"] && element["children"].length() > 0
child = element["children"]
+ @text = ""
for item in child do
- if item["type"] == nil && item["text"]
- @text = item["text"]
+ if item["type"] == nil && item["text"]
+ @text += item["text"]
end
end
- end
+ end
@element = element
@attributes = element["attrs"]
end
end
- def item_type
+ def item_type
@itemType ? @itemType : nil
end
- def style_type
+ def style_type
@styleType ? @styleType : nil
end
- def item_uid
+ def item_uid
@itemUid ? @itemUid : nil
end
- def content_type_uid
+ def content_type_uid
@contentTypeUid ? @contentTypeUid : nil
end
- def text
+ def text
@text
end
- def element
+ def element
@element
end
-
- def attributes
+
+ def attributes
@attributes
end
@@ -62,8 +63,8 @@ def get_attribute_value(string)
@attributes.attribute(string) ? @attributes.attribute(string).value : nil
else
@attributes[string]
- end
+ end
end
end
end
-end
\ No newline at end of file
+end
diff --git a/spec/lib/model/option_spec.rb b/spec/lib/model/option_spec.rb
index 23be650..d590621 100644
--- a/spec/lib/model/option_spec.rb
+++ b/spec/lib/model/option_spec.rb
@@ -1,6 +1,6 @@
require 'spec_helper'
-def getMetadata(itemType=nil, styleType=nil, linkText=nil)
+def getMetadata(itemType=nil, styleType=nil, linkText=nil)
html = "
#{linkText}
" end it 'Should return link string with blank href for link node type' do doc = getJson(BlankDocument) - + result = subject.render_node('a', doc, linkText) expect(result).to eq "#{linkText}" end it 'Should return link string for link node type' do doc = getJson(LinkInPJson)["children"][0] - + result = subject.render_node('a', doc, linkText) expect(result).to eq "#{linkText}" end it 'Should return image string with blank src for image node type' do doc = getJson(BlankDocument) - + result = subject.render_node('img', doc, linkText) expect(result).to eq "#{linkText}" end it 'Should return code string for code node type' do doc = getJson(BlankDocument) - + result = subject.render_node('code', doc, linkText) expect(result).to eq "
#{linkText}"
end
it 'Should return blank string for reference node type' do
doc = getJson(BlankDocument)
-
+
result = subject.render_node('reference', doc, linkText)
expect(result).to eq ""
end
diff --git a/spec/mock/json_to_html_mock.rb b/spec/mock/json_to_html_mock.rb
index 170067b..8a002b5 100644
--- a/spec/mock/json_to_html_mock.rb
+++ b/spec/mock/json_to_html_mock.rb
@@ -42,6 +42,7 @@
EntryReferenceBlockJson = '{ "uid":"06e34a7 5e4 e549d ", "_version":1, "attrs":{ }, "children":[{"uid":"70f9b 325075d43 128c0d0 aa3eb7f291f","type":"reference","attrs":{"display-type":"block","entry-uid":"entry_uid_1","content-type-uid":"content_block","locale":"en-us","type":"entry","class-name":"embedded-entry"},"children":[{"text":""}]}],"type":"doc"}'
EntryReferenceLinkJson = '{ "uid":"06e34a7 5e4 e549d", "_version":1, "attrs":{ }, "children":[{"uid":"7626ea98e0e95d602210","type":"reference","attrs":{"target":"_self","href":"/copy-of-entry-final-02","display-type":"link","entry-uid":"entry_uid_2","content-type-uid":"embeddedrte","locale":"en-us","type":"entry","class-name":"embedded-entry"},"children":[{"text":"/copy-of-entry-final-02"}]}],"type":"doc"}'
EntryReferenceInlineJson = '{ "uid":"06e34a7 5e4 e549d", "_version":1, "attrs":{ }, "children":[{"uid":"506 4878f3f46 s21f0cbc aff","type":"reference","attrs":{"display-type":"inline","entry-uid":"entry_uid_3","content-type-uid":"embeddedrte","locale":"en-us","type":"entry","class-name":"embedded-entry"},"children":[{"text":""}]}],"type":"doc"}'
+EntryReferenceLinkTextJson = '{ "uid":"06e34a7 5e4 e549d", "_version":1, "attrs":{ }, "children":[{"uid":"7626ea98e0e95d602210","type":"reference","attrs":{"target":"_self","href":"/copy-of-entry-final-02","display-type":"link","entry-uid":"entry_uid_3","content-type-uid":"embeddedrte","locale":"en-us","type":"entry","class-name":"embedded-entry"},"children":[{"text":"L\'Oreal Paris Telescopic Lift "},{"text":"Washable","italic":true},{"text":" Mascara"}]}],"type":"doc"}'
HRJson = '{ "uid":"06e34a7 5e4 e549d", "_version":1, "attrs":{ }, "children":[{"uid":"f5a7b57 40a8a5c3 576828276b","type":"hr","children":[{"text":""}],"attrs":{ }}],"type":"doc"}'
H1NonChildJson = '{ "uid":"06e34a7a449d7fc2acd","_version":13,"attrs":{ },"children":[{ "type":"h1","attrs":{ },"uid":"c2dfed70 4d7030c65e2e1"}],"type":"doc"}'
@@ -144,4 +145,4 @@
}
}
- EmbedEdges = '{"edges":[{"node":{"system":{"content_type_uid":"sys_assets","uid":"entry_uid_5"},"created_at":"2020-08-19T09:13:05.864Z","updated_at":"2020-09-10T09:35:28.393Z","created_by":"created_at_date","updated_by":"created_at_date","content_type":"image/png","file_size":"36743","filename":"svg-logo-text.png","url":"/v3/svg-logo-text.png","_version":7,"title":"svg-logo-text.png","description":""}},{"node":{"system":{"content_type_uid":"sys_assets","uid":"asset_uid_1"},"created_at":"2020-08-19T09:13:32.785Z","updated_at":"2020-08-19T09:13:32.785Z","created_by":"created_at_date","updated_by":"created_at_date","content_type":"application/pdf","file_size":"13264","filename":"title","url":"/v3/dummy.pdf","_version":1,"title":"dummy.pdf"}},{"node":{"title":"Update this title","url":"","locale":"en-us","system":{"uid":"entry_uid_1","content_type_uid":"content_block"},"_version":5,"_in_progress":false,"multi_line":"","rich_text_editor":""}},{"node":{"title":"updated title","rich_text_editor":[""],"locale":"en-us","system":{"uid":"entry_uid_3","content_type_uid":"embeddedrte"},"_in_progress":false}},{"node":{"title":"Entry with embedded entry","rich_text_editor":[""],"locale":"en-us","system":{"uid":"entry_uid_2","content_type_uid":"embeddedrte"},"_in_progress":false}},{"node":{"system":{"uid":"entry_uid_6","content_type_uid":"sys_assets"},"content_type":"image/png","file_size":"36743","filename":"svg-logo-text.png","url":"/v3/svg-logo-text.png","title":"svg-logo-text.png","description":""}},{"node":{"title":"Update this title","url":"","locale":"en-us","system":{"uid":"entry_uid_1","content_type_uid":"content_block"},"_version":5,"_in_progress":false,"multi_line":"","rich_text_editor":""}},{"node":{"title":"updated title","rich_text_editor":[""],"locale":"en-us","system":{"uid":"entry_uid_3","content_type_uid":"embeddedrte"},"_in_progress":false}},{"node":{"title":"Entry with embedded entry","rich_text_editor":[""],"locale":"en-us","system":{"uid":"entry_uid_2","content_type_uid":"embeddedrte"},"_in_progress":false}}]}'
\ No newline at end of file
+ EmbedEdges = '{"edges":[{"node":{"system":{"content_type_uid":"sys_assets","uid":"entry_uid_5"},"created_at":"2020-08-19T09:13:05.864Z","updated_at":"2020-09-10T09:35:28.393Z","created_by":"created_at_date","updated_by":"created_at_date","content_type":"image/png","file_size":"36743","filename":"svg-logo-text.png","url":"/v3/svg-logo-text.png","_version":7,"title":"svg-logo-text.png","description":""}},{"node":{"system":{"content_type_uid":"sys_assets","uid":"asset_uid_1"},"created_at":"2020-08-19T09:13:32.785Z","updated_at":"2020-08-19T09:13:32.785Z","created_by":"created_at_date","updated_by":"created_at_date","content_type":"application/pdf","file_size":"13264","filename":"title","url":"/v3/dummy.pdf","_version":1,"title":"dummy.pdf"}},{"node":{"title":"Update this title","url":"","locale":"en-us","system":{"uid":"entry_uid_1","content_type_uid":"content_block"},"_version":5,"_in_progress":false,"multi_line":"","rich_text_editor":""}},{"node":{"title":"updated title","rich_text_editor":[""],"locale":"en-us","system":{"uid":"entry_uid_3","content_type_uid":"embeddedrte"},"_in_progress":false}},{"node":{"title":"Entry with embedded entry","rich_text_editor":[""],"locale":"en-us","system":{"uid":"entry_uid_2","content_type_uid":"embeddedrte"},"_in_progress":false}},{"node":{"system":{"uid":"entry_uid_6","content_type_uid":"sys_assets"},"content_type":"image/png","file_size":"36743","filename":"svg-logo-text.png","url":"/v3/svg-logo-text.png","title":"svg-logo-text.png","description":""}},{"node":{"title":"Update this title","url":"","locale":"en-us","system":{"uid":"entry_uid_1","content_type_uid":"content_block"},"_version":5,"_in_progress":false,"multi_line":"","rich_text_editor":""}},{"node":{"title":"updated title","rich_text_editor":[""],"locale":"en-us","system":{"uid":"entry_uid_3","content_type_uid":"embeddedrte"},"_in_progress":false}},{"node":{"title":"Entry with embedded entry","rich_text_editor":[""],"locale":"en-us","system":{"uid":"entry_uid_2","content_type_uid":"embeddedrte"},"_in_progress":false}}]}'