[2.0] scala template encoding

Showing 1-6 of 6 messages
[2.0] scala template encoding Roman Bykovskiy 3/15/12 2:42 AM
When I check source code of page made by scala template in browser I see text encoded like this: Стол № - why?
Re: [2.0] scala template encoding Yan A 3/16/12 6:03 AM
and if string hardcoded in template "пример" - it outputs correctly,
if from @obj.prop - outputs like $#xxxx;


On Thursday, March 15, 2012 1:42:33 PM UTC+4, Roman Bykovskiy wrote:
When I check source code of page made by scala template in browser I see text encoded like this: Стол № - why?
Re: [2.0] scala template encoding Yan A 3/16/12 6:45 AM
Pramework always calls  

org.apache.commons.lang.StringEscapeUtils.escapeHtml(text) 

for any string passed to template engine to output
Re: [2.0] scala template encoding Yan A 3/16/12 6:58 AM
Apache's escape is very straitforward - escapes all non-asci.

    public void escape(Writer writer, String str) throws IOException {
        int len = str.length();
        for (int i = 0; i < len; i++) {
            char c = str.charAt(i);
            String entityName = this.entityName(c);
            if (entityName == null) {
                if (c > 0x7F) {
                    writer.write("&#");
                    writer.write(Integer.toString(c, 10));
                    writer.write(';');
                } else {
                    writer.write(c);
                }
            } else {
                writer.write('&');
                writer.write(entityName);
                writer.write(';');
Re: [2.0] scala template encoding Freewind 3/16/12 7:07 AM
You can use @Html(xxx) instead of @xxx to tell play2 not encode them
Re: [2.0] scala template encoding Roman Bykovskiy 3/16/12 7:19 AM
But it's complicated to put every variable in wrapper and also what if I need to escape html tags but not to escape alph chars?

пятница, 16 марта 2012 г. 18:07:15 UTC+4 пользователь Freewind написал: