Git Product home page Git Product logo

Comments (5)

jjlauer avatar jjlauer commented on August 28, 2024 2

@ismail-codar latest version includes a new @with feature that lets you define variables.

from rocker.

jjlauer avatar jjlauer commented on August 28, 2024

Local variable assignment would be a useful feature. If you wanted to take
a stab at implementing it, I'd be happy to review the PR.

Just one comment on your included code though -- seems like a lot of logic
to put inside a template. Wouldn't it be cleaner to fetch(url)... in a
controller, get the response, and then call your template with the result?

On Mon, May 2, 2016 at 5:42 PM, ismail-codar [email protected]
wrote:

My template like this:

fetch(url).then(function(response) {
response.json().then(function (@raw(SwaggerUtil.responseTypeName(entryValue.getJsonObject("responses")) == "void" ? "" : data)) {
resolve(@raw(SwaggerUtil.responseTypeName(entryValue.getJsonObject("responses")) == "void" ? "" : data));
});
})

But SwaggerUtil.responseTypeName(.. function calling 2 times.
Can I use it like following

@localvar rType = SwaggerUtil.responseTypeName(entryValue.getJsonObject("responses"))fetch(url).then(function(response) {
response.json().then(function (rType == "void" ? "" : data)) {
resolve(rType == "void" ? "" : data);
});
})


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#26

from rocker.

ismail-codar avatar ismail-codar commented on August 28, 2024

I looked at your code. It looks hard for me. I am not ANTLR family. Some developer documentation may be usefull.

I have used rocker in one project. A swagger schema to client generator template is here.

I want to share my views.I also would like to hear your thoughts.

Rocker is very fast and very easy to use. Thanks your work. Especially hot reloading support helped me while developing templates. Otherwise it takes a lot of time.

According to me {% %} like delimiter used template is more readable. For example

@args (String packageName, String className, Map itemMap)
class YourClass {
@if(some logic) {
some code
}
}

{ and } are intermixing and readability is falling.

Mostly templates aims multi language usability. Like https://mustache.github.io/ And rocker syntax looks can be adopted different platform. If the authors is not the purpose of this! embedding java codes in template feature would be very useful. Thinking wider than local variable assignment. Loops, if else conditions and variable declerations, assigments etc can be used with embedding java code.

from rocker.

jjlauer avatar jjlauer commented on August 28, 2024

Appreciate your feedback. It's cool you're using Rocker to help generate a
template that outputs a Java class.

In my opinion, templates should not have much actual logic. Rocker
supports for loops against your data model, but it sounds like you want for
loops running in embedded Java code as well. I think that only encourages
putting more logic in your templates than you should. Plus, templates can
already just call out to other Java code already, so you could pretty
easily put that type of logic in a standard Java utility class as well.
That encourages a better design in my opinion, since it makes unit testing
that kind of logic much easier. I can see the advantage of supporting
local variable assignment, but I'd be a hard sell on much other embedded
Java code like you suggested.

On Wed, May 4, 2016 at 1:07 AM, ismail-codar [email protected]
wrote:

I looked at your code. It looks hard to me. I am not antlr family. Some
developer documentation may be usefull.

I have used rocker in one project. A swagger schema to client generator
template is here
https://github.com/ismail-codar/codegen-maven/blob/master/src/main/resources/views/swagger/qbit/client/typescript/ServiceClient.rocker.html.

I want to share my views.I also would like to hear your thoughts.

Rocker is very fast and very easy to use. Thanks your work. Especially hot
reloading support helped me while developing templates. Otherwise it takes
a lot of time.

According to me {% %} like delimiter used template is more readable. For
example

@Args (String packageName, String className, Map itemMap)class YourClass {@if(some logic) {
some code
}
}

{ and } are intermixing and readability is falling.

Mostly templates aims multi language usability. Like
https://mustache.github.io/ And rocker syntax looks can be adopted
different platform. If the authors is not the purpose of this! embedding
java codes in template feature would be very useful. Thinking wider rather
than local variable assignment. Loops, if else conditions can be used with
embedding java code.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#26 (comment)

from rocker.

localvar avatar localvar commented on August 28, 2024

hmmm, just to check why I was @.

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.