compiling .pm file for sending to webserver without creating a file
#24
Closed
opened 4 years ago by somesayinice
·
8 comments
Loading…
Reference in New Issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Good afternoon. Just wondering if anyone else has tackled a similar problem. I'm trying to publish directly to a website using the website's api. I can connect successfully, get a response with authentication.
However, the data I've been sending is just junk data. What I'm trying to do now is raco pollen render without actually creating a file. I would like to output to a string which I can then send to the webserver for publishing or storage in sql or whatever. Does anyone have any ideas about how to output from a pollen markup file to a string?
I am thinking I should create a template.api file and do the work within the template file. Then create a poly-target called api. My only? problem, since ignorance is bliss, is I don't know how to stop the generation of a file.
Thanks much.
raco pollen render
is just a convenience for using the underlyingrender
function frompollen/render
. You could call this directly with a source name to get a string.Thank you for the quick reply and for the insight. So right now I have four files: pollen.rkt, template.api, test_source.poly.pm, api_test.rkt. Runing the api_test.rkt allows me to get the string output I desire and of course I can send this output to the website api.
But as you can see from the code, it is not dynamic so I'm not sure how to use it without manually editing this .rkt every single time. Ideally, I'd be able to place this in pollen.rkt so that I can build from sublime and it would process the .pm file and send the data to the website. But this doesn't seem to make any sense.
Thanks again for the help. I'll keep bashing along.
I jury-rigged the dry run feature. I changed
[wants-dry-run? (for-each message expanded-source-paths)]
to[wants-dry-run? (for-each render expanded-source-paths)]
in render.rkt. Now I can runraco pollen render -d -t api \"$file\"
to output the string without generating the file and it fits in my workflow.And it is also likely a very bad way to solve the problem. I am very open to learning how to do it better.
I think I understand — you want to use
raco pollen render
to cause I/O side effects, but not leave behind any files. I suppose we could add a switch for this purpose. Is there a common terminology for this behavior in other command-line tools?That is exactly what I was trying to do. I'm not sure what the terminology is though with other command-line tools. But if dry-run means printing the name of the affected file, maybe a term like console-output might work? Thanks much again. Your help has made a big difference.
I have added this option. It is called
--null
or-n
and will suppress the file output of a render:raco pollen render -n foo.html
Added by
fc5ca9f659
Thanks so much!