I am pulling html email content from a database. The html contains strings like :
<%# include view="MirrorPage" %> and <%= stagingArea.techField.label %>
that I would like to remove before displaying.
I'm using Coldfusion 9 and jSoup to parse the html. jSoup worked great removing <script> content that was in the html.
<cfset emailHTML=jsoup.parse(detail["html"]) />
<cfset emailHTML.select("script").remove() />
I just unclear on how to select <% with jSoup since it isn't a true "tag".
Thanks,
Gary
When you use jSoup to parse HTML which contains <%# ... %> it gets converted to <%# ... %> and is treated as text.
Since it is simple text, there's no way for jSoup to pick it up, or treat it any different to other text.
Assuming these markers are placeholders/tokens that follow simple rules (i.e. there's no nesting, they wont contain '%' outside of their markers, etc), you can remove them with a regex like this:
<cfset emailHTML = rereplace( emailHTML.html() ,'<%[#=][^%]+%>','','all') />
(You may or not want to then use jsoup.parse(emailHTML) to get the string back into an object again.)
Of course, if these placeholders are there for a reason, you may need to do something more complex than simply removing them - and if they might be including HTML then you need to consider if they should be processed before jSoup is invoked to remove script tags/etc.
Related
I'm new in phoenix. I need to display all the posts and pictures to them on the main page. I written below code in my index template:
<img src="<%= Blog.Image.url({#post.image, #post}, signed: true) %>">
And i got this
lib/blog_web/templates/post/index.html.heex:19:21: expected closing " for attribute value
What i missing?
The HEEx documentation notes:
...code interpolation using <%= ... %> and <% ... %> are restricted to the body (inner content) of the HTML/component nodes and it cannot be applied within tags.
Instead, there is specific HEEx syntax attribute={expression} for interpolating attribute values. In your example, you'd use
<img src={Blog.Image.url({#post.image, #post}, signed: true)}>
The engine will correctly insert quotation marks and other escaping as required (or, if Blog.Image.url/2 returns nil, omit the attribute entirely).
I am using a third party indexing service (Swiftype) to search through my database. The returned records contains a property called highlight. This simply adds <em> tags around matching strings.
I then bind this highlight property in Ember.JS Handlebars as such:
<p> Title: {{highlight.title}} </p>
Which results in the following output:
Title: Example <em>matching</em> text
The browse actually displays the <em> tags, instead of formatting them. I.e. Handlebars is not identifying the HTML tags, and simply printing them as a string.
Is there a way around this?
Thanks!
Handlebars by default escapes html, to prevent escaping, use triple brackets:
<p> Title: {{{highlight.title}}} </p>
See http://handlebarsjs.com/#html-escaping
Ember escapes html because it could be potentional bad code which can be executed. To avoid that use
Ember.Handlebars.SafeString("<em>MyString</em>");
Here are the docs
http://emberjs.com/guides/templates/writing-helpers/
if you've done that you could use {{hightlight.title}} like wished,...
HTH
First of all, what is a viewstate?
In testautomation I probably need to correlate this value as it is unique for every user logging in?
How can I get the 'value' / token below using regex?
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTUxOTg3NDM2NGQYCAUkY3RsMDAkTWFpbk1lbnUkTWVudSRjdGwwMSRjdGwwMCRNZW51DxQrAA5kZGRkZGRkPCsABQACBWRkZGYC/////w9kBSRjdGwwMCRNYWluTWVudSRNZW51JGN0bDAzJGN0bDAwJE1lbnUPFCsADmRkZGRkZGQ8KwAEAAIEZGRkZgL/////D2QFJGN0bDAwJE1haW5NZW51JE1lbnUkY3RsMDQkY3RsMDAkTWVudQ8UKwAOZGRkZGRkZDwrAAcAAgdkZGRmAv////8PZAUkY3RsMDAkTWFpbk1lbnUkTWVudSRjdGwwNiRjdGwwMCRNZW51DxQrAA5kZGQCAmRkZDwrAAkAAglkZGRmAv////8PZAUkY3RsMDAkTWFpbk1lbnUkTWVudSRjdGwwMiRjdGwwMCRNZW51DxQrAA5kZGQCAmRkZDwrAAsAAgtkZGRmAv////8PZAUpY3RsMDAkRm9vdGVyUmVnaW9uJGN0bDAwJEZvb3RlckxpbmtzJExpc3QPD2ZkZAUTY3RsMDAkY3RsMDMkUnNzTGlzdA8PZmRkBSRjdGwwMCRNYWluTWVudSRNZW51JGN0bDA1JGN0bDAwJE1lbnUPFCsADmRkZGRkZGQ8KwAJAAIJZGRkZgL/////D2R3kjxauWd2eu+C/bmZz+/bI7YRkg==" />
Read this: RegEx match open tags except XHTML self-contained tags
then if you still want to have a go, use this:
(?<=input )(?:.*)(value\=\".*\")
I have htmltext as
<p>Here is what some pupils told me about how they prepared for and fared in yesterday's preliminary round.</p>
<hr />
<p>"I will stay calm and try my best. If I do not know a word, I will just have to put something down."</p>
<p><strong>some text</strong></p>
<hr />
<p>"I am more confident than last year because I have experience. I read the newspaper and I looked through the dictionary for difficult words and tagged them."</p>
<p><strong>some text</strong></p>
<hr />
I am displaying the same as textarea.htmlText .
But the textarea displays the above with too many blank lines in between them. Is there a way i can remove the line breaks in the text? the text is coming as it is from server side.
Style the p tag in CSS.
Example:
p{
line-height:0.5;
}
In SilverStripe 3, How can I put multiline comments in template file ?
single line comments can be done with <%-- my comment --%> (or the html way <!-- my comment --> which will be sent to the browser, but hidden not displayed.)
as far as I know, there is no multiline comment in silverstripe templates.
An ugly work around would be <% if false %>, like so:
<% if false %>
some
comment
text
here
<% end_if %>