danielgtaylor/aglio

Local template and Body iteration?

Opened this issue ยท 2 comments

I don't know if this is a request, a question, or a bug. ๐Ÿ˜„

I'm trying to do two things:

  1. Instead of using the built-in highlight on Req/Resp bodies, I want to iterate over the lines, and literally wrap them in p or span elements. (Needed to output to a content system that can't handle pre-formatted code/text, so I need to style with inline css...long story.) If I can get the key/values that's even better so I can format them differently, but I'll take what I can get. ๐Ÿ˜„

I can't quite figure out the format of the object delivered in request.body.

I tried each thing in request.body followed by p= request.body.thing and request.body[thing] and clearly I'm not accessing the object properly. This is either probably something very simple, or very impossible. I'm not above rewriting or patching something if needed.

  1. This is even more basic. I have a folder, with just:
example.apib
index.jade
mixins.jade

copied from the theme branch. But no matter what I try, it often seems to try to ignore my updated mixins.jade, presumably pulling from the node install dir.
The command line I use is:

aglio -i example.apib --theme-template ./index.jade -o foo.jade

And I've tried various methods of include, like ./mixins.jade, mixins.jade, and tried an absolute path but that requires setting a Jade basedir option that I don't know how to do if you're not using the JS API directly.

Thank you in advance on both issues/questions; this will REALLY help me solve a big project.

Update: I learned about NOCACHE which helps with some confusing things, and (duh) -n for relative paths. So now I can render each time fine, but still don't understand how to iterate over the object. Continued thanks :)

Gasol commented
  1. Instead of using the built-in highlight on Req/Resp bodies, I want to iterate over the lines, and literally wrap them in p or span elements. (Needed to output to a content system that can't handle pre-formatted code/text, so I need to style with inline css...long story.) If I can get the key/values that's even better so I can format them differently, but I'll take what I can get. ๐Ÿ˜„

I can't quite figure out the format of the object delivered in request.body.

I have generated the sample output of example.apib provided by Aglio by drafter to you for reference, Please take a look at https://gist.github.com/Gasol/8db57237f2a13636b6efe1abfdba4043#file-example-ast-json-L64, The value of request.body is just simple string.

I tried each thing in request.body followed by p= request.body.thing and request.body[thing] and clearly I'm not accessing the object properly. This is either probably something very simple, or very impossible. I'm not above rewriting or patching something if needed.

I believe the following snippets is what you need to modify with your own logic, Please let me know if you still have problems.

aglio/templates/mixins.jade

Lines 129 to 133 in c52a482

if request.body
h5 Body
pre: code
!= self.highlight(request.body, null, ['json', 'yaml', 'xml', 'javascript'])
div(style="height: 1px;")