Method: Slaw::Render::HTMLRenderer#render_node
- Defined in:
- lib/slaw/render/html.rb
#render_node(node, base_url = '') ⇒ String
Transform just a single node and its children into HTML.
If elem has an id, we use xpath to tell the XSLT which element to transform. Otherwise we copy the node into a new tree and apply the XSLT to that.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/slaw/render/html.rb', line 45 def render_node(node, base_url='') params = _transform_params({'base_url' => base_url}) if node.id params += ['root_elem', "//*[@id='#{node.id}']"] doc = node.document else # create a new document with just this element at the root doc = Nokogiri::XML::Document.new doc.root = node params += ['root_elem', '*'] end _run_xslt(:fragment, doc, params) end |