I've created a HTMLMacro (as well as a simple ButtonMacro) that allows you to put arbitrary HTML code into your snips.
The
attached war file contains these macros, it is based on 1.0b1-uttoxeter.
You use it like this:
{html}
Your <b>html</b> here.
{html}The code is as follows:
package org.snipsnap.render.macro;import java.io.IOException;
import java.io.Writer;import org.radeox.util.Encoder;
import org.radeox.util.i18n.ResourceManager;
import org.snipsnap.render.macro.parameter.SnipMacroParameter;/**
* Macro that renders HTML directly.
*
* @author mfranken
*/
public class HTMLMacro extends SnipMacro {
public String getName() {
return "html";
} public String getDescription() {
return ResourceManager.getString("i18n.messages", "macro.html.description");
} /**
* Writes out HTML code directly.
*
* Use as follows: <code>{html}code{html}</code>
*
* @see org.snipsnap.render.macro.SnipMacro#execute(java.io.Writer, org.snipsnap.render.macro.parameter.SnipMacroParameter)
*/
public void execute(Writer writer, SnipMacroParameter params) throws IOException { if (params.getLength() == 0) {
writer.write(Encoder.unescape(params.getContent()));
return;
} else {
throw new IllegalArgumentException("Number of arguments does not match");
}
}
}Make sure you add the following stuff to src/META-INF/services/org.radeox.macro.Macro
org.snipsnap.render.macro.HTMLMacro
and to your messages.properties, e.g. src/apps/default/WEB-INF/classes/i18n/message_en.properties this:
# HTML Macro
macro.html.description=Render any HTML directly.
jsawers here. I could not get it to work from the war file download. So I took the source code and packaged it up properly, so it can be dropped into any install like a
regular macro. I ended up tweaking the package names, but the code is all
mfranken. I attached HTMLMacro.jar so you can download it.
DaveLevy For users of the Java Server, the .jar need only be copied to the library directory named in the CLASSPATH.