function to output whole HTML element

48 views
Skip to first unread message

Rob Shepherd

unread,
Jan 6, 2017, 12:59:34 PM1/6/17
to Pebble Templating Engine
Hi,

I've made a pebble extension function to output a CSRF HTML input tag.

CsrfToken token = (CsrfToken) ViewUtils.getRequest().getAttribute("_csrf");
String output = String.format("<input type='hidden' id='csrf' name='%s' value='%s' >", token.getParameterName(), token.getToken());
return new SafeString(output);


This outputs a valid CSRF input tag wherever I call csrfInput() in the template.


Is there a better way of doing this, to output a whole HTML element, other than a function?


Cheers


Rob

Reply all
Reply to author
Forward
0 new messages