RejectedSoftware Forums

Sign up

Diet template error

Hello, i learn vibe.d and crete simple blog.
I transfer to diet template array:
string[string] postData;

And try show post data, like example on this page:
http://vibed.org/docs
extends layout

block body

h1 Example page - Home: #{postData}
p Hello, World!
	- foreach(i, post; postData)
			| #{i}. #{post}
			


I get error:
[B71EFF80:00000000 INF] You are up to date
Compiling diet template 'index.dt' (compat)...
diet.d(285): Error: "template index.dt line 6: Indentations may
not skip child levels.(diet.d:304)"
diet.d(304): called from here:
this.assertp(nextindentlevel <= level + 1,"Indentations may not
skip child levels.","diet.d",304)
diet.d(345): called from here:
parser.buildBodyWriter(nodestack,level,instring)
diet.d(272): called from here:
this.buildBodyWriter(nodestack,nextindentlevel,instring)
diet.d(128): called from here: parser.buildWriter()
diet.d(76): called from here: dietParser()
diet.d(76): Error: argument to mixin must be a string, not
(dietParser())
diet.d(285): Error: "template index.dt line 6: Indentations may
not skip child levels.(diet.d:304)"
diet.d(304): called from here:
this.assertp(nextindentlevel <= level + 1,"Indentations may not
skip child levels.","diet.d",304)
diet.d(345): called from here:
parser.buildBodyWriter(nodestack,level,instring)
diet.d(272): called from here:
this.buildBodyWriter(nodestack,nextindentlevel,instring)
diet.d(128): called from here: parser.buildWriter()
diet.d(76): called from here: dietParser()
diet.d(76): Error: argument to mixin must be a string, not
(dietParser())
/opt/vibe/source/vibe/http/server.d(634): Error: template
instance
vibe.templ.diet.parseDietFileCompat!("index.dt",HttpServerRequest,"req",string[string],"postData")
error instantiating
source/app.d(32): instantiated from here:
renderCompat!("index.dt",HttpServerRequest,"req",string[string],"postData")
source/app.d(32): Error: template instance
vibe.http.server.HttpServerResponse.renderCompat!("index.dt",HttpServerRequest,"req",string[string],"postData")
error instantiating
Failed: 'dmd' '-debug' '-g' '-w' '-property' '-g'
'-I/opt/vibe/source' '-Isource' '-Jviews' '-Isource' '-Jviews'
'-L-levent_pthreads' '-L-levent' '-L-lssl' '-L-lcrypto' '-v'
'-o-' 'source/app.d' '-Isource'

Re: Diet template error

I'm remove one tabulation:
extends layout

block body

h1 Example page - Home: #{postData}
p Hello, World!
      - foreach(i, post; postData)
          | #{i}. #{post}
			

And now i get error:
index.dt(7): Error: undefined identifier i, did you mean template
to(T)?
index.dt(7): Error: undefined identifier post
/opt/vibe/source/vibe/http/server.d(634): Error: template
instance
vibe.templ.diet.parseDietFileCompat!("index.dt",HttpServerRequest,"req",string[string],"postData")
error instantiating
source/app.d(32): instantiated from here:
renderCompat!("index.dt",HttpServerRequest,"req",string[string],"postData")
source/app.d(32): Error: template instance
vibe.http.server.HttpServerResponse.renderCompat!("index.dt",HttpServerRequest,"req",string[string],"postData")
error instantiating
Failed: 'dmd' '-debug' '-g' '-w' '-property' '-g'
'-I/opt/vibe/source' '-Isource' '-Jviews' '-Isource' '-Jviews'
'-L-levent_pthreads' '-L-levent' '-L-lssl' '-L-lcrypto' '-v'
'-o-' 'source/app.d' '-Isource'

Re: Diet template error

I found trouble, i use spaces, but to diet need tabulations :(
Did you planed make HTML templates?

Re: Diet template error

Am 25.08.2012 21:36, schrieb Sergey:

I found trouble, i use spaces, but to diet need tabulations :(
Did you planed make HTML templates?

I should actually work with both, tabs and spaces. It tries to
auto-detect the indentation style based on the first indented line. But
in this case the indentation of the last two lines is off and it fails
to detect this - this is definitely a bug that needs to be fixed. I'll
also rephrase the error message for the first example to make it more
clear what exactly is wrong.

A plain-text based alternative template system similar to what PHP does
was roughly planned, but the syntax still needs to be defined.

Re: Diet template error

The current master version now has better indentation checks and a
better error message for the first example. Tabs and spaces should now
both be robust.