nedbat / cog

Small bits of Python computation for static files
MIT License
340 stars 26 forks source link

Write output without cog source #13

Closed aidan-gallagher closed 4 years ago

aidan-gallagher commented 4 years ago

Is it possible to write the generator code without the cog python source code embedded in it.

I don't think it would be too hard to parse the output myself and remove all cog statements however I'd prefer to use the libraries functionality if I can.

nedbat commented 4 years ago

My first thought is, why use cog if you only want the generated output? That sounds like a Python program with print statements. Can you say more about why it would be useful?

aidan-gallagher commented 4 years ago

Thanks for the quick reply Ned.

Reasons I want to have the cog source in 1 repo which will be shared across projects. Each project will generate a different file based off of a config file which will be stored in each projects repo.

I don't want the generated code in the shared repo because it is different per project. I don't want the cog source in the project repo because then it is duplicated & other smaller reasons.

What Cog gives me With Cog I can write a template .cpp/.h file. It is clear what remains constant and what changes. <--- The main reason
I get some wee bonuses like Output line suffixes if I want.

Without Cog I could replace each cog.outl call with a print or write to file command. I would also have to call print/write for all the constant bits of code.

After writing this I'm beginging to wonder if Cog isn't the right tool for me.

aidan-gallagher commented 4 years ago

I think i'm going to use jinja instead.