Comments (5)
@ismail-codar latest version includes a new @with
feature that lets you define variables.
from rocker.
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.
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.
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.
hmmm, just to check why I was @.
from rocker.
Related Issues (20)
- 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
- How to configure Rocker to use GuavaHtmlStringify? HOT 4
- Support Java 17 HOT 2
- Why rocker dont import List class? HOT 2
- Gradle 7 support
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.