How to use stipple at compile time?

Issue #2 resolved
Tiago Ribeiro created an issue

Hi, I'm not having much luck using stipple during compile-time, calling new Template().fromString(....) from inside a macro.

I'm trying to build index.html from a bunch of html partials at compile time to reduce that task on the server for each request.

Any ideas how this can be done? Meanwhile I'm generating a small app instead and run it to compile the file.

This is the hxml file without creating the small app:

-cp src/html
-lib stipple
-lib hxparse
-lib compiletime
--macro "Build.build()"
--next .....

and this is creating the small app

-cp src/html
-main Build
-lib stipple
-lib hxparse
-lib compiletime
-neko app.n
-cmd neko src/html/app.n
--next .....

edit - at compiletime i also have compilation errors if the macro fails to build the template, running the program generates no errors if something is wrong.

Comments (10)

  1. Niel Drummond repo owner

    Can you try again with the flag -D stipple_noprecompile ? This option was added to build templates at runtime, but since you are building in a macro, you should be precompiling anyway.

  2. Tiago Ribeiro reporter

    Oops, okay, after adding the stipple_noprecompile i am getting the error i always had:

    It comes from: parseListAST -> offsetPosition -> Context.getPosInfos-> load(..) Invalid Call

    If i use a template like simple string it works fine. As soon as i add a field to it like simple {{field}} i get that error.

  3. Niel Drummond repo owner

    You will not need to pass the self: Expr argument, because the signature using -D stipple_noprecompile falls back to the following signature:

    public function fromString(tpl: String)

  4. Niel Drummond repo owner

    Ah right, yeh it's possible that might be an issue.. It's caused in AST.hx (and other places I'm not sure).

  5. Tiago Ribeiro reporter

    Anyway this may not be that important, i have it working by creating the small neko file and run it when i compile, it seems that the compilation stops if there is a runtime error too so everything is going ok.

  6. Log in to comment