Re: Custom encoding a string value
Daniel Dekany <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
Tuesday, December 1, 2009, 2:18:23 PM, martijn.list wrote: > Hi, > > I would like to add my own string encoding to Freemarker. > > I would like to encode a string to quoted-printable format. There are > built-in encodings like ?html. Is it possible to add for example ?QP > (for quoted printable)? > > What is the best approach for me? Write a #function or a TemplateMethodModelEx for it, and put that in a file that you #import (or #include) everywhere. Or, write a TemplateMethodModelEx and set it as shared variable in the Configuration object. In any case, you will be able to do something like this: qp(theExpression), but not theExpression?qp, since ?stuff is reserved for core stuff (mostly that's why it exist at all). Another possibility is that you contribute and then ?qp can be part of the next FreeMarker release (and immediately of he nightly build). Note that QP is a charset-aware algorithm, so it need a charset parameter that defaults to .output_encoding, just like in the case of ?url. > Kind regards, > > Martijn Brinkers > > > ------------------------------------------------------------------------------ > Join us December 9, 2009 for the Red Hat Virtual Experience, > a free event focused on virtualization and cloud computing. > Attend in-depth sessions from your desk. Your couch. Anywhere. > http://p.sf.net/sfu/redhat-sfdev2dev > _______________________________________________ > FreeMarker-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/freemarker-user > -- Best regards, Daniel Dekany ------------------------------------------------------------------------------ Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev