aglio icon indicating copy to clipboard operation
aglio copied to clipboard

Local template and Body iteration?

Open rtgoodwin opened this issue 5 years ago • 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.

rtgoodwin avatar Jun 05 '19 14:06 rtgoodwin

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 :)

rtgoodwin avatar Jun 05 '19 14:06 rtgoodwin

  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.

https://github.com/danielgtaylor/aglio/blob/c52a482e5392849de12ce1cf43245ad66da44745/templates/mixins.jade#L129-L133

Gasol avatar Jun 07 '19 16:06 Gasol