Git Product home page Git Product logo

Comments (10)

rockswang avatar rockswang commented on July 4, 2024 3

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.

jjlauer avatar jjlauer commented on July 4, 2024

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.

TaekSoonJang avatar TaekSoonJang commented on July 4, 2024

Thanks for input! I will look into it :)

from rocker.

rockswang avatar rockswang commented on July 4, 2024

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.

jjlauer avatar jjlauer commented on July 4, 2024

Neat use case. I believe your use case should work. I'm guessing your
regex is wrong. Here's the default regex:

https://github.com/fizzed/rocker/blob/master/rocker-compiler/src/main/java/com/fizzed/rocker/compiler/JavaGeneratorMain.java#L50

.*.rocker.(raw|html|sql)$

from rocker.

denuno avatar denuno commented on July 4, 2024

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.

robertotru avatar robertotru commented on July 4, 2024

@denuno that won't help. As pointed out by @rockswang, the problem relies in the ContentType enum rather than in the regex.

from rocker.

denuno avatar denuno commented on July 4, 2024

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.

robertotru avatar robertotru commented on July 4, 2024

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.

denuno avatar denuno commented on July 4, 2024

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)

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.