I am trying to embed a link in a localized string for display on a view. So far what I have will work in en-US, but when I change the default language to Turkish the text displayed does not contain a useful link nor are most string substitutions made.
The IHtmlLocalizer syntax that works for en-US is
#Localizer["Click {0} to return to the {1} application.", #Html.Raw(#String.Format("{0}", #Localizer["here"].Value, #Model.PostLogoutRedirectUri)), #Model.ClientName].Value
Producing "Click here to return to the named applicatio." With here being a function link.
When I change to Turkish I get the following results. "{1} uygulamasına geri dönmek için {0} tıklayın."
#model LoggedOutViewModel
#using CompanyName.Server
#using Microsoft.AspNetCore.Mvc.Localization
#inject IHtmlLocalizer<SharedResources> Localizer
<div class="page-header logged-out">
#if (Model.PostLogoutRedirectUri != null)
{
<div>
#Localizer["Click {0} to return to the {1} application.", #Html.Raw(#String.Format("{0}", #Localizer["here"].Value, #Model.PostLogoutRedirectUri)), #Model.ClientName].Value
</div>
}
</div>
}
Expected results
"named uygulamasına geri dönmek için İşte tıklayın."
with the word İşte being a valid link.
Actual results
"{1} uygulamasına geri dönmek için {0} tıklayın."
Related
I have data like this :
data: {
content:"<p><span style=\"font-size:16px\">Berikut adalah beberapa pemberontakan yang pernah terjadi di daerah.</span></p>\r\n\r\n<p><span style=\"font-size:16px\"><strong>1. Pemberontakan Angkatan Perang Ratu Adil (APRA) </strong></span></p>\r\n\r\n<ul>\r\n\t<li><span style=\"font-size:16px\">di Bandung, pada 23 Januari 1950.</span></li>"
}
From the data I want to display it using Vue js.
This is my Vue js code:
<div class="row px-3" v-html="data.content"></div>
And if the above code is executed then the result is like this :
You can see, \r \n and \t don't seem to be rendering by Vue js
How to get \r \n and \t to be rendered by Vue js and can display as below?
\r, \n, and \t are not valid HTML; they are escape sequences that are used in other languages (so expecting them to work in HTML would be like pasting python code into a javascript file and expecting it to run.) You need to replace them with HTML that does what you want it to do. For new lines, the <br> tag could be used, but traditionally people handle line breaks by wrapping their sections in paragraphs (<p>) or divs (<div>). For tabs, you'll need to google for how to handle indenting in HTML as there is a lot more to say about it than I can explain in a short answer here.
I don't have the complete code, but after first read :
Try
v-html="content"
and
data(){
return {
content: "<p><span style=\"font-size:16px\">Berikut adalah beberapa pemberontakan yang pernah terjadi di daerah.</span></p>\r\n\r\n<p><span style=\"font-size:16px\"><strong>1. Pemberontakan Angkatan Perang Ratu Adil (APRA) </strong></span></p>\r\n\r\n<ul>\r\n\t<li><span style=\"font-size:16px\">di Bandung, pada 23 Januari 1950.</span></li>"
}
}
i am trying to pass a parameter to an app using existDB , my problem is while using the templates , it gives me this error :
templates:NotFound No template function found for call app:getBusPorMatricula [at line 189, column 85, source: C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
In function:
templates:call(item(), element(), map) [135:36:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
templates:process(node()*, map) [146:81:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
templates:process(node()*, map) [146:81:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
templates:process(node()*, map) [146:81:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
templates:process(node()*, map) [462:17:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
templates:surround(node(), map, xs:string, xs:string?, xs:string?, xs:string?) [34:9:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
templates:call-with-args(function, function*, element(), map) [208:13:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
templates:process-output(element(), map, item()*, element()) [205:9:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
templates:call-by-introspection(element(), map, map, function) [187:28:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
templates:call(item(), element(), map) [135:36:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
templates:process(node()*, map) [131:51:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
templates:process(node()*, map) [88:9:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
templates:apply(node()+, function, map?, map?) [45:5:C:\Users\rober\Documents\eXist\webapp\WEB-INF\data\expathrepo\shared-0.4.0\content\templates.xql]
And the code that i actually have is this one , i have all the code that is auto generated while you created an app equal except this files:
app.xql:
xquery version "3.0";
module namespace app="http://gijonapp1.es/templates";
declare namespace bus="http://docs.gijon.es/sw/busgijon.asmx";
import module namespace templates="http://exist-db.org/xquery/templates" ;
import module namespace config="http://gijonapp1.es/config" at "config.xqm";
(:~
: This is a sample templating function. It will be called by the templating module if
: it encounters an HTML element with an attribute data-template="app:test"
: or class="app:test" (deprecated). The function has to take at least 2 default
: parameters. Additional parameters will be mapped to matching request or session parameters.
:
: #param $node the HTML node with the attribute which triggered this call
: #param $model a map containing arbitrary data - used to pass information between template calls
:)
declare function local:getNumeroBusesFuncionando()
{
let $numero:=count(doc('http://datos.gijon.es/doc/transporte/busgijontr.xml')//bus:posicion)
return $numero
};
declare function local:getBusesFuncionando()
{
<buses numero="{local:getNumeroBusesFuncionando()}">{
for $bus in doc('http://datos.gijon.es/doc/transporte/busgijontr.xml')//bus:posicion
order by xs:integer($bus/bus:idlinea)
return <bus>{$bus/bus:matricula,$bus/bus:idlinea,$bus/bus:idtrayecto,$bus/bus:utmx,$bus/bus:utmy}</bus>}
</buses>
};
declare function app:showMenu($node as node(), $model as map(*)){
<div>
<ul>
<li>Buses Funcionando</li>
<form action="./busPorMatricula.html">
Inserte la matricula del autobus a buscar :
<input type="text" name="matricula"/>
<input type="submit" value="Buscar"/>
</form>
</ul>
</div>
};
declare function app:showBusFuncionando($node as node(), $model as map(*)) {
<div>
<h2> Buses funcionado a las {hours-from-time(current-time())}:{minutes-from-time(current-time())}</h2>
<ul>
{
for $bus in local:getBusesFuncionando()//bus
return <li><b>Linea :{$bus/bus:idlinea}</b> Trayecto : {$bus/bus:idtrayecto} Matricula : {$bus/bus:matricula} Posicion : {$bus/bus:utmx},{$bus/bus:utmy}</li>
}
</ul>
</div>
};
(: !!!!!The PROBLEM is HERE !!!!:)
declare function app:getBusPorMatricula($node as node(), $model as map(*))
{
let $matricula:=request:get-parameter('matricula', '')
let $bus :=doc('http://datos.gijon.es/doc/transporte/busgijontr.xml')//bus:posicion[bus:matricula=$matricula]
return
<p>asd</p>
};
And this are the pages that use the templates :
index.html:
<div xmlns="http://www.w3.org/1999/xhtml" data-template="templates:surround" data-template-with="templates/page.html" data-template-at="content">
<h1> Menu </h1>
<div data-template="app:showMenu"/>
</div>
busPorMatricula.html:
<div xmlns="http://www.w3.org/1999/xhtml" data-template="templates:surround" data-template-with="templates/page.html" data-template-at="content">
<h1> Bus con matricula </h1>
<div data-template=" app:getBusPorMatricula" data-template-matricula="{request:get-parameter('matricula', ''}"/>
</div>
What i am trying to do with all this is given a registration number , show some information of the bus with that number
Thanks for the help
I have found the error , it was in the code of the html in "busPorMatricula.html"
there is a space in the content of the data-template and that was the problem.
I hope it helps others ,I have spent like 4 hours looking for one hundred more complicated things than that.
i'm using jeditable jquery with asp.net c#. I have a string which has to be edited, but when i edit it the whole html code come together. I want to edit only the title.
string initialHtml = "<P><B style='LINE-HEIGHT: 20px'><IMG class=iconEsquerda height=16 src='../images/arquivo_word.gif' width=16> <A href='5Pregão 40-13 Manutenção preventiva e corretiva em ventilador pulmonar - HAN - 12.0090.pdf' target=_blank><FONT color=#456db8>### TITLE - EDIT ME!!!!### </FONT></A></B></P>";
If I have a form on a JSP like this:
<form action = "/myApp/myServlet?rssFeedURL=${rssFeedURL}' />" method = "post">
<input type = "button" value = "See data for this RSS feed."/>
</form>
What I find is that if the variable ${rssFeedURL} has no query string, then the server receives it properly, e.g.:
http://feeds.bbci.co.uk/news/rss.xml
But if a query string exists, e.g.:
http://news.google.com/news?ned=us&topic=m&output=rss
I expect that it is to do with the encoding of the '&' character. Can anyone advise?
The server receives only:
http://news.google.com/news?ned=us
My pages are charset=UTF-8 encoded.
You need to URL-encode request parameters. Otherwise they will be interpreted as part of the initial request URL.
JSTL offers you the <c:url> for this.
<c:url var="formActionURL" value="/myApp/myServlet">
<c:param name="rssFeedURL" value="${rssFeedURL}" />
</c:url>
<form action= "${formActionURL}" method="post">
...
An alternative is to create an EL function which delegates to URLEncoder#encode().
it is simple html:
<%--
<a href="?language=de">
<img src="/Images/Company/de.png" alt="Webseite auf Deutsch" style="border: 0;" />
</a>
--%>
i would like to make from them html.actionlink:
<%= Html.ActionLink("", "ChangeCulture", "Account", new { lang = "de", returnUrl = this.Request.RawUrl }, new { #style = "background-image: url(/Images/Company/de.png)", #class = "languageLink" }) %>
I would like to have my link without text. it doesn't work, null in a first parameter its not allowed. image is to short as normal. how can i use html.actionlink without text but with image??
Here is a solution.
<a href="<%= Url.RouteUrl("MyRoute", new { id = Model.Id }) %>">
<img src="myimage.png" alt="My Image" />.
</a>
Essentially, ActionLink is for text links and there isn't an equivalent for images, but you can use Url.RouteUrl to get the address for the link and put any HTML code you like inside of the anchor (W3C permitting of course).
This way is easiest (using Razor):
<img src="myimage.png" alt="My Image" />
based on a previous SO question (that was closed), here's a solution:
public static string ImageLink(this HtmlHelper htmlHelper,
string imgSrc, string alt,
string actionName, string controllerName, object routeValues,
object htmlAttributes, object imgHtmlAttributes)
{
UrlHelper urlHelper = ((Controller)htmlHelper.ViewContext.Controller).Url;
string imgtag = htmlHelper.Image(imgSrc, alt, imgHtmlAttributes);
string url = urlHelper.Action(actionName, controllerName, routeValues);
TagBuilder imglink = new TagBuilder("a");
imglink.MergeAttribute("href", url);
imglink.InnerHtml = imgtag;
imglink.MergeAttributes(new RouteValueDictionary(htmlAttributes), true);
return imglink.ToString();
}
the orignal can be found here: Is there an ASP.NET MVC HtmlHelper for image links?
Here is my humble contribution, using Razor (as an example) for when a Font Awsome character is used as an image:
<p>
#Html.ActionLink(" ", "Create", "RouteName", new { id = Model.ID }, new { #class = "fas fa-plus text-center" })
</p>
The character in between the two quotes is alt+255 (hit the ALT key, then key-in 255 on the num keyboard, then release the ALT key).
Indeed, neither "" nor " " nor string.Empty work with ActionLink, but alt-255 does. This is a very old trick (from the DOS days) to display a hidden blank character. So far I have not encountered any problems with this trick.