3 ms·
Something in the article I don't understand: > Cog lets you use the full power of Python for text generation, without a templating system dumbing down your too
by mjd 3y ago
Something in the article I don't understand:
> Cog lets you use the full power of Python for text generation, without a templating system dumbing down your tools for you.
I would have said that Cog is a templating engine. What distinction is the author drawing here?
- codetrotter 3y agoI think the difference is that some templating engines have a DSL that lets you do things like loop over arrays and such, and that compared to those Cog is different.
- lifthrasiir 3y agoMany if not most templating engines do not allow an arbitrary code because of security implications.
- PurpleRamen 3y agoCog seem to be the type that just evals normal python.code. While many other template-engines replicate code-structures. For example, in Jinja2 you would write something like "{% for i in data %}{{i}}{% endfor %}", which looks kinda like python, and utilizes python-object, but is not real python-code.
- HelloNurse 3y agoGood code at the expense of "syntactic noise" in templates: a suitable tradeoff for the typical use case of short and precise templates with advanced logic backing them (e.g. the DCT coefficient tables linked in another comment) rather than large outputs with simple logic to keep the templates readable (e.g. a dynamic web page, the typical use of Jinja).