Comments (10)
Hi jjlauer,
The error is not caused by the suffixRegex, it seems that the ContentType enum only support RAW & HTML extensions.
Here's the stack trace:
at com.fizzed.rocker.maven.GenerateMojo.execute(GenerateMojo.java:160)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
... 20 more
Caused by: java.lang.IllegalArgumentException: Unsupported content type for extension [raw1] for template name [CorpBuildVisibilityGraph.rocker.raw1]
at com.fizzed.rocker.compiler.RockerUtil.templateNameToContentType(RockerUtil.java:152)
at com.fizzed.rocker.compiler.TemplateParser.parseIdentity(TemplateParser.java:120)
at com.fizzed.rocker.compiler.TemplateParser.parse(TemplateParser.java:130)
at com.fizzed.rocker.compiler.JavaGeneratorMain.run(JavaGeneratorMain.java:105)
at com.fizzed.rocker.maven.GenerateMojo.execute(GenerateMojo.java:157)
... 22 more
from rocker.
Rocker was designed to support other file formats. For example, it
supports an ending of ".raw" currently which basically disables escaping
rules. Adding support for .json would probably be pretty cool. Its fairly
trivial adding a new file format. I'd do a search for ".raw" and ".html"
in the codebase to see where you'd plug it in.
Rocker would probably be pretty amazing at rendering json quickly and
efficiently. PRs would be welcome!
-Joe
On Fri, Mar 18, 2016 at 9:33 PM, 장택순 [email protected] wrote:
As I look through README.md, Rocker seems to handle rocker.html file by
default. Can it be used to other formats like JSON?—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#23
from rocker.
Thanks for input! I will look into it :)
from rocker.
Dear author,
I am using Rocker for SQL generation, it works like a charm!
I'd like the template suffix to be .rocker.sql, so that it can be opened by Eclipse SQLEditor by default, however I found only .rocker.html & .rocker.raw is allowed even if I've set ''suffixRegex" to ".*.rocker.sql$".
Is that possible to allow scanning any files that matches the pattern, and simply set "discardLogicWhitespace=false" be default?
from rocker.
Neat use case. I believe your use case should work. I'm guessing your
regex is wrong. Here's the default regex:
.*.rocker.(raw|html|sql)$
from rocker.
I'd like to be able to use different extensions as well. Any chance of modifying the JavaGeneratorRunnable regex to:
- this.suffixRegex = ".*\\.rocker\\.(raw|html)$";
+ this.suffixRegex = ".*\\.rocker\\..*?$";
So folks can add custom handling by extension if they want, but it'll pick up all rocker templates by default?
from rocker.
@denuno that won't help. As pointed out by @rockswang, the problem relies in the ContentType enum rather than in the regex.
from rocker.
Right on, I should have looked a little closer.
Conceptually though, I'm thinking "pick up anything with *.rocker.*
by default, and then check for registered extensions/stringifiers" versus say looking only for registered extensions, if that sounds good.
Ideally I guess it'd be an option or something, if there's some reason not do that (e.g. a convention that I'm not aware of-- I'm just using this for JSON and some batch/bash script generation stuff, haven't looked at the web aspect of Rocker ironically).
I'd be using .bat
, .sh
, and .json
extensions (and thinking about IDE integration, it would probably be nifty to have customizable tokens so you could use existing editors somehow, perhaps via comments in the language-- still percolating on that bit, but dig IDE integration.), and I see .sql
in the comments...
If the globing works (glomming onto *.rocker.*
), I don't mind refactoring things a bit to add those extensions/content types, maybe with some stringy-thingies in the spirit of the HTML ones if any come to mind. I'm not going to add custom tokens or anything like that but perhaps something to keep in mind for later (I haven't looked at that code at all, just a bit at the content type stuff-- not a clue what I'm talking about difficulty-wise with tokes and such).
from rocker.
I use things like Bla.xml.raw
or Foo.json.raw
and then set the IDE (IntelliJ) to recognize xml.raw
as XML and json.raw
as JSON. Not a big drama at the end.
from rocker.
That works too!
There's a convention though, so I figure roll with that, contribution-wise.
Pretty much everything has stuff that needs to be escaped -- XML is a good candidate for instance -- though I haven't even looked at that stuff since I'm using .raw as well. (Which works fine, I just like the library, and low-hanging fruit.
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.