Reputation: 283
I'm trying to develop an application using Rails 4.0.
At some point my application receives an html marked-up text from user (some sort of template) and it has to detect some placeholders which will be filled, later, with the data user provides in the future, for mass mailing. Each placeholder is contained inside an <span>
tag with class attribute set to dynamic
.
Here lies my question: What is the quickest way to extract these placeholder (text inside span
tags) to create the list I need? Is there any kind of ruby library that could help me with that?
Upvotes: 0
Views: 64
Reputation: 6043
Consider using nokogiri gem to parse.
doc.search('span.dynamic').each do |dynamic|
puts dynamic.content
end
When doc
is a variable who receives a Nokogiri::HTML
. See this wiki to get better examples.
Upvotes: 2