Grails - Japanese Contribute a tag

????? {excerpt:hidden=true}Contribute a Tag {excerpt}!

{excerpt:hidden=true}This page contains user submissions of custom tags that may or may not be included in the Grails core. {excerpt} ???????Grails?????????????????????????????????????????????????? {excerpt:hidden=true}Add your tag below. {excerpt} ?????Contribute a tag ???????????

?? {excerpt:hidden=true}Tags {excerpt}

?????????? dateFormat Tag

?? {excerpt:hidden=true}Description {excerpt}

{excerpt:hidden=true}Allows formatting of data objects. {excerpt} ??????????????????????

? {excerpt:hidden=true}Example {excerpt}

<g:dateFormat value="${new Date()}" format="dd-MM-yyyy" />

?????? {excerpt:hidden=true}The Code {excerpt}!

def dateFormat = { attrs ->
out << new java.text.SimpleDateFormat(attrs.format)
.format(attrs.value)
}

??????? esc Tag

?? {excerpt:hidden=true}Description {excerpt}

{excerpt:hidden=true}Escapes HTML entities within its body to ensure no cross-site scripting (XSS) attacks can work. {excerpt} ??????????????(XSS)???????????????????HTML?????????

? {excerpt:hidden=true}Example {excerpt}

<g:esc>${someobj.name}</g:esc>

?????? {excerpt:hidden=true}The Code {excerpt}!

private static final String AMP = "&amp;"
private static final String LT = "&lt;"
private static final String GT = "&gt;"
private static final String QUOTE = "&quot;"

/** * Escape HTML entities within the body. */ def esc = { attrs, body -> def text = ''

if(body instanceof Closure) { text = TagLibUtil.outToString(body, attrs) } else if(body instanceof String) { text = body } else if(attrs instanceof String) { text = attrs }

out << escapeEntities(text); }

/** * Return the given string with all HTML entities escaped into their * HTML equivalent. * * @param text String containing unsafe characters. * @return <var>text</var> with characters turned into HTML entities. */ public static String escapeEntities(String text) { if (text == null) text = "" String trim = text.trim() char[] c = trim.toCharArray()

StringBuffer buffer = new StringBuffer() def i = -1; while (++i < c.length) { if (c[i]=='&') buffer.append(AMP) else if (c[i]=='<') buffer.append(LT) else if(c[i]=='>') buffer.append(GT) else if(c[i]=='"') buffer.append(QUOTE) else buffer.append(c[i]) } return buffer.toString() }