Method: Kentico::Kontent::Delivery::Resolvers::InlineContentItemResolver#resolve
- Defined in:
- lib/delivery/resolvers/inline_content_item_resolver.rb
#resolve(content, inline_items) ⇒ Object
Resolves all inline content items in the content.
-
Args:
-
content (
string
) The string value stored in the element -
inline_items (
Array
) ContentItems referenced by the content from the ‘modular_content’ JSON node
-
-
Returns:
-
string
The original content passed, with all <object data-type=“item”> replaced with custom output
-
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/delivery/resolvers/inline_content_item_resolver.rb', line 23 def resolve(content, inline_items) doc = Nokogiri::HTML.parse(content).xpath('//body') = doc.xpath('//object[@type="application/kenticocloud"][@data-type="item"]') .each do |tag| output = resolve_tag tag, inline_items el = doc.at_xpath( '//object[@type="application/kenticocloud"][@data-type="item"][@data-codename=$value]', nil, value: tag['data-codename'] ) el.swap(output) unless output.nil? end doc.inner_html end |