Created
January 15, 2012 03:59
-
-
Save osima/1614236 to your computer and use it in GitHub Desktop.
ore-ore-macro-test code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyMacroFilter extends org.radeox.filter.MacroFilter { | |
private MacroRepository macros | |
private MacroRepository getMacros(){ | |
if(macros==null) | |
macros = new MacroRepository() | |
macros | |
} | |
public void setInitialContext(InitialRenderContext context) { | |
getMacros().setInitialContext(context) | |
} | |
protected Repository getMacroRepository() { | |
getMacros() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab(group='radeox', module='radeox', version='1.0-b2') | |
import org.radeox.engine.context.BaseInitialRenderContext | |
import org.radeox.macro.parameter.MacroParameter | |
import org.radeox.macro.BaseMacro | |
import org.radeox.macro.MacroLoader | |
import org.radeox.filter.FilterPipe | |
import org.radeox.engine.BaseRenderEngine | |
class MyRenderEngine extends BaseRenderEngine{ | |
MyRenderEngine(){ super(new BaseInitialRenderContext()) } | |
@Override | |
protected void init() { | |
if (fp == null) { | |
fp = new FilterPipe(initialContext); | |
def filter = new org.radeox.filter.MacroFilter() | |
fp.addFilter( filter ) | |
//new MacroLoader().add( filter.getMacroRepository(), new TestMacro() ) | |
def macro = new TestMacro() | |
filter.macroRepository.put( macro.name, macro ) | |
} | |
} | |
String render(wikitext){ | |
super.render( wikitext, initialContext ) | |
} | |
} | |
class TestMacro extends BaseMacro { | |
String getName() { 'test' } | |
void execute(Writer writer, MacroParameter params) { | |
writer << "<test>${params.getContent()}</test>" | |
} | |
} | |
def wikitext = ''' | |
{test} | |
テスト領域 | |
{test} | |
''' | |
println new MyRenderEngine().render(wikitext) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment