def body_splited_by_paywall return body if paywall_placeholder.blank? return body unless body.include?(paywall_placeholder) Nokogiri::HTML.fragment(%( #{body.split(paywall_placeholder)[0]} #{Grid::Core::Post::PAYWALL_PLACEHOLDER} )).to_html end def paywall_placeholder @paywall_placeholder ||= if body_editor == 'verstka' Nokogiri::HTML(body).css('[data-anchor-value="paywall"]').first.to_s else Grid::Core::Post::PAYWALL_PLACEHOLDER end end
O(N)