- edited description
How to use stipple at compile time?
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)
-
reporter -
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. -
reporter Ok, what should i pass to the argument self:Expr?
-
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 CallIf i use a template like
simple string
it works fine. As soon as i add a field to it likesimple {{field}}
i get that error. -
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)
-
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).
-
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.
-
repo owner Can you try again with the latest commit ?
-
reporter Wow, such an easy fix, thanks! (worked)
-
repo owner - changed status to resolved
Thanks for reporting!
- Log in to comment