nedbat / cog

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

indirect-vs-inline-python #23

Open dreftymac opened 1 year ago

dreftymac commented 1 year ago

indirect-vs-inline-python

Overview

Context

Scenario

Example

BEFORE

## Simple demo just to show what we want
* just print a hello world message
* a random number of times for variability
* include a random integer for more variability

##@ [[[cog cog.out('Hello {vxx:03d} World!\n'.format(vxx=random.randint(0,999))*random.randint(1,3)) ]]]
Hello 009 World!
Hello 009 World!
##@ [[[end]]]

##@ [[[cog cog.out('Hello {vxx:03d} World!\n'.format(vxx=random.randint(0,999))*random.randint(1,3)) ]]]
Hello 371 World!
##@ [[[end]]]

AFTER

## Simple demo just to show what we want
* just print a hello world message
* a random number of times for variability
* include a random integer for more variability

##@ <cogbeg coggid="uu190hello1678463240" coguri="py003010" >
Hello 772 World!
Hello 772 World!
Hello 772 World!
##@ <cogend>

##@ <cogbeg coggid="uu195hello1678463240" coguri="py003010" >
Hello 371 World!
##@ <cogend>

Feature request

Workaround

See also