Comments (5)
That's what BindableRockerModel is for. It lets you create templates
dynamically w/ a map.
The preferred method is preferred for a reason. If you change the
arguments to a template, you want your compilation process to break, in
order to catch the issues you're refactoring caused. If you are passing
around a lot of context-specific arguments to your templates, then I highly
suggest you add a parent Model you extend from that has some of that
instead.
-Joe
On Tue, Sep 20, 2016 at 12:46 PM, joselightware [email protected]
wrote:
On static templates passing all params on template(arg1, arg2, arg3 ...)
can get really really messy when dealing with complex templates since
quickly you have to check which param corresponds to a @tag
https://github.com/tag.
A much better approach would be to use a map of strings to assign values
to the corresponding tag and pass the map as the template argument.HashMap<String, String> hmap = new HashMap<String, String>();
hmap.put("name", "fizzed");
hmap.put("last", "rocker");
hmap.put("age", "25");String result = MyTemplate.template(hmap).render().toString();
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#36, or mute the thread
https://github.com/notifications/unsubscribe-auth/AAjwAj4QhsGdgPGUJxh59ZMj-L8Dsi20ks5qsA3PgaJpZM4KB26C
.
from rocker.
I've seen on the documentation the BindableRockerModel the only problem is that I cant figure out what path to provide to make it work.
After fixing issue #37 I can make use of static template like so
TestTemplate.template("Hello World").render().toString();
the path to the compiled template is
"src/main/java/com/joe/template/TestTemplate.java"
the path to the template file is
"src/main/resources/joe/template/TestTemplate.rocker.html"
Now i'm trying to make use of the BindingRockerModel
I've tested the following paths without success
Rocker.template("com/joe/template/TestTemplate.rocker.html")
.bind("world", "Hello Rocker!")
.render()
.toString();
}
Rocker.template("src/main/resources/com/joe/template/TestTemplate.rocker.html")
.bind("world", "Hello Rocker!")
.render()
.toString();
}
Rocker.template("src/main/java/com/jo/template/TestTemplate.rocker.html")
.bind("world", "Hello Rocker!")
.render()
.toString();
}
All with the same exception as result (com.fizzed.rocker.TemplateNotFoundException)
Any idea of what I might be doing wrong.
from rocker.
The path is the package +template name.
So if your template gets a package of "views" and is named
"index.rocker.html" then you'd say:
Rocker.template("views/index.rocker.html")
On Tue, Sep 20, 2016 at 3:49 PM, joselightware [email protected]
wrote:
I've seen on the documentation the BindableRockerModel the only problem is
that I cant figure out what path to provide to make it work.After fixing issue #37 #37 I can
make use of static template like soTestTemplate.template("Hello World").render().toString();
the path to the compiled template is
"src/main/java/com/jo/template/TestTemplate.java"
the path to the template file is
"src/main/resources/jo/template/TestTemplate.rocker.html"
Now i'm trying to make use of the BindingRockerModel
I've tested the following paths without success
Rocker.template("com/jo/template/TestTemplate.rocker.html")
.bind("world", "Hello Rocker!")
.render()
.toString();
}Rocker.template("src/main/resources/com/jo/template/TestTemplate.rocker.html")
.bind("world", "Hello Rocker!")
.render()
.toString();
}Rocker.template("src/main/java/com/jo/template/TestTemplate.rocker.html")
.bind("world", "Hello Rocker!")
.render()
.toString();
}All with the same exception as result (com.fizzed.rocker.
TemplateNotFoundException)
Any idea of what I might be doing wrong.—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#36 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAjwAq3Qvnac3Y47Eyyn7CidXEQLIACrks5qsDi8gaJpZM4KB26C
.
from rocker.
Ok, now its working ^_^
from rocker.
Now we have a fully working gradle rocker plugin, the plugin is a mix of many of the thing I use that has nothing to do with rocker so ill strip down the parts that aren't related and PM you the main steps to make a working gradle-rocker-plugin since you might want to re-use your clases instead of my implementation, at the end of the day gradle support both java and groovy.
from rocker.
Related Issues (20)
- Using template in RockerBody does not produce expected result HOT 1
- rocker-compiler.conf is in incorrect folder HOT 1
- Centralized conditional RockerContent rendering ? HOT 2
- Document required template extensions
- GraalVM compatibility HOT 4
- Warnings in Gradle Plugin (@Input annotation used on property of type 'File') HOT 6
- call java function in template HOT 1
- rocker-maven-plugin templateDirectory
- With block invalid: multiple equals symbols found for assignment String href = "/abc?x=y"
- [Doc] it's unclear how to instantiate Rocker
- Loading templates from classpath / jar ? HOT 1
- Parentheses right after variable HOT 2
- Compile time include postprocessor
- support Java 11 HOT 1
- Github latest release points to outdated release.
- Unable to get hot-reload working with tomcat server HOT 3
- Question about formatting
- Generation crashes with NPE if a non-normal file is present in the template directory HOT 1
- Global default null value rendering to avoid NPEs
- it's abandoned? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rocker.