multi-line in aurelia component html attribute property - html

This is a weird question about possibly embedding a string in an aurelia html file within the attribute tag but I would like to keep my tab and line formatting.
So, in my TS file I have the following:
this.queryDateStart += "type=EntityOne&dateQueryString=";
this.queryDateStart += "" +
"eOr( " +
"eAnd( " +
"eAnd( facetName:isExcluded AND facetValue:No );" +
"dAnd( facetName:deadlineDate AND "+ dateRangePredicate + ");" +
"); " +
"dOr( " +
"(facetName:excludedUntilDate AND "+ dateRangePredicate + ")" +
");" +
");"
And instead of having the following:
<section as-element="ab-deadlines" data-query="${queryDateStart}"></section>
I would like to actually pass the literal string from above.
But with the line spaces.
Would that break anything?
So for example ( going to try this today) - in my html file I would put:
<section as-element="ab-deadlines"
data-query="
eOr(
eAnd(
eAnd( facetName:isExcluded AND facetValue:No );
dAnd( facetName:deadlineDate AND ${dateRangePredicate} );
);
dOr(
(facetName:excludedUntilDate AND + ${dateRangePredicate} )
);
);"></section>

About breaking: it shouldn't break anything. In the end, it's just normal HTML attribute, and as long as the spec allows it, it works in Aurelia, as Aurelia works directly, and plainly with HTML elements.
You can see it yourself at this sandbox https://codesandbox.io/s/z20qx0q263

Related

How to do " or \r in Prism.js in Angular6

So I'm trying to have Prism highlight the following Arduino code snippet on my site.
client.print(String(\'\'GET \'\') + url + \'\' HTTP/1.1\r\n\'\' +
\'\'Host: \'\' + host + \'\'\r\n\'\' +
\'\'Connection: close\r\n\r\n\'\');
I initially had to change all of the " to '' but now it interprets \r\n as a line break and displays it as such. Any thoughts?
Ok, actually just got it. Use \'\'\\r\'\' to express what will be interpreted as "\r".

Mix html and code asp.net

I'm trying to join two strings but I want them to be divided by a break line.
This is my code:
<td>#(string.Join("<br /> ", report.TimeReportProjects.Select(x => x.Project.ProjectName)))</td>
<td>#(string.Join("<br /> ", report.TimeReportProjects.Select(x => x.Description.Shorten(35))))</td>
<td>#(data.StartHour + ":" + data.StartMinute.ToString("00") + " - " + data.EndHour + ":" + data.EndMinute.ToString("00"))</td>
<td>#(Math.Floor(hours) + ":" + TimeSpan.FromHours(hours).Minutes.ToString("00"))</td>
The "br/>" tag will just be read as a string which is not to strange I assume, I know if i want to mix html code in a code block I should use #: but I am not sure how to use that in this case.
There is a Html.Raw method that should help you. It can be applied like so:
<td>#Html.Raw(string.Join("<br />", report.TimeReportProjects.Select(x => x.Project.ProjectName)))</td>

GWT html object show text as url or img

I get a URL as text from database and put it into an HTML object and add this object to layout.
I want this text to work as URL or IMG.
you can see in the code what I have tried. didn't find a method that does that...
my code :
int listSize = result.size();
int i;
assetPanel.clear();
for(i=0;i<listSize;i++)
{
HorizontalPanel vPanelPic = new HorizontalPanel();
HTML picSpace = new HTML();
picSpace.setHTML("<img src = " + result.get(i).getUrl() + "style=width:304px;height:228px>");
//Window.alert("<a href " + result.get(i).getUrl()+ "</a>");
vPanelPic.add(picSpace);
assetPanel.add(vPanelPic);
}
Your HTML is invalid. Try this:
// img:
picSpace.setHTML("<img src='" + result.get(i).getUrl() + "' style='width:304px;height:228px'>");
// link:
Window.alert("<a href='" + result.get(i).getUrl() + "'>URL</a>");
I think that post solves the problem without any security issues :
For SafeHtml, Do we need to sanitize the "link" in <img src=link> tag, GWT?

Including special chars in htmlText

How can I include special characters in htmlText? Specifically, I need to include this symbol: Ø. So far I tried ∅, \u2205 and \u2300, but the symbol is never shown. Copying the char itself only works with text property, so what is the appropriate way to include special chars?
This is my code:
this.text1.htmlText = toHtmlText(s);
function toHtmlText(s:String):String{
return "<font size=\"32\">" +
"\u2205" + // also tried '∅' and '\u2300'
" </font><font size=\"64\">" +
s +
"</font>";
}
try this,
this.text1.htmlText = toHtmlText(s);
function toHtmlText(s:String):String{
return "<font size=\"32\">" +
"\Ø" +
" </font><font size=\"64\">" +
s +
"</font>";
}
find all special characters here: http://dev.w3.org/html5/html-author/charref
Use this following HTML entity:
Ø
You can also go through this link http://www.utexas.edu/learn/html/spchar.html

Displaying div tag in a textbox

I am saving the below div tag into SQL DB:
String StrDiv = "<div STYLE=" + "''"+"font-family: " + lblPreviewPane.Font.Name + "; font-size: " + lblPreviewPane.Font.Size + "; color: " + ColorPicker1.Color + ""+"''" + ">" + lblPreviewPane.Text + "</div>";
The below query is used to update the message:
String sqlUpdate = "update iweb_messages set message='" + StrDiv +
"'where site_id ='" + mSiteID + "' and page_id ='" + ddlSitePage.SelectedValue + "'";
I retrieve the div from DB and display it in a textbox and a label.
In the label, the div tag is displayed as: messagetoday21
But in the textbox, the div tag is displayed as:
<div STYLE='font-family: Times New Roman; font-size: 18pt; color: #CC3399'>today21</div>
I need to display the text alone in the textbox also(same as displayed in the Label).
Kindly help me with some suggestions.
I use the below code to display the text from the DB in the textbx and label:
String sqlMsg = "select message from iweb_messages where site_id='" + mSiteID + "' and page_id='" + ddlSitePage.SelectedValue + "'";
DataView dvMsg = dbLib.GetDateView(sqlMsg);
if (dvMsg.Table.Rows.Count > 0)
{
txtOutputMessage.Text = dvMsg.Table.Rows[0]["message"].ToString();
lblPreviewPane.Text = dvMsg.Table.Rows[0]["message"].ToString();
}
I assume your "textbox" is a textarea? If so, the behavior you're seeing is expected, because you're generating HTML that looks like this:
<textarea><div STYLE='font-family.....></div></textarea>
The content of a TEXTAREA is displayed without HTML rendering. Whereas the label (assuming it's a span or another div) will render the HTML.
So, as a quick fix, you need to save lblPreviewPane.Text to your database in addition to the full <div>; then display the value of lblPreviewPane.Text in your text box instead of the <div>.
But I would also question the wisdom of storing the full <div> in the database. If the font attributes need to be determined ahead of time, then I think you would be better off storing those attribute values in the table, then building the formatted <div> when it is being displayed.