Git Product home page Git Product logo

Comments (5)

jjlauer avatar jjlauer commented on June 26, 2024

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.

lethevimlet avatar lethevimlet commented on June 26, 2024

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.

jjlauer avatar jjlauer commented on June 26, 2024

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 so

TestTemplate.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.

lethevimlet avatar lethevimlet commented on June 26, 2024

Ok, now its working ^_^

from rocker.

lethevimlet avatar lethevimlet commented on June 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.