Unverified Commit 7905c567 authored by Martin Monperrus's avatar Martin Monperrus Committed by GitHub
Browse files

doc: specify inline template definition

parent d9046916
......@@ -80,6 +80,24 @@ method.getBody().insertBegin(injectedCode);
```
### Inline templates
Templates can be made inline, if the source code of the transformation is passed appropriately, as an anonymous class, as follows:
```java
// example of inline template definition + instantiation
Template t = new StatementTemplate() {
TemplateParameter<Collection<?>> _col_ = createVariableAccess(method.getParameters().get(0));
@Override
public void statement() {
if (_col_.S().size() > 10)
throw new OutOfBoundException();
}
}; // end of inline template
CtStatement injectedCode = t.apply();
```
### Kinds of templating
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment