Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.recipe.template
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Romain Courteaud
slapos.recipe.template
Commits
1d6b316c
Commit
1d6b316c
authored
Jan 06, 2021
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jinja2: Prevent 'once' from overwriting 'rendered'
See merge request
nexedi/slapos.recipe.template!5
parent
065564b0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
1 deletion
+38
-1
slapos/recipe/template/README.jinja2.txt
slapos/recipe/template/README.jinja2.txt
+37
-0
slapos/recipe/template/jinja2_template.py
slapos/recipe/template/jinja2_template.py
+1
-1
No files found.
slapos/recipe/template/README.jinja2.txt
View file @
1d6b316c
...
...
@@ -555,3 +555,40 @@ Removing the canary allows template to be re-rendered::
>>> cat('foo_once')
dummy
It's also possible to use the same file for ``rendered`` and ``once``::
>>> write('buildout.cfg',
... '''
... [buildout]
... parts = template
...
... [template]
... recipe = slapos.recipe.template:jinja2
... template = inline:initial content
... rendered = rendered
... once = ${:rendered}
... ''')
>>> run_buildout() # doctest: +ELLIPSIS
Uninstalling template.
Installing template.
The template install returned None. A path or iterable os paths should be returned.
Template was rendered::
>>> cat('rendered')
initial content
When buildout options are modified, the template will not be rendered again::
>>> with open('buildout.cfg', 'a') as f:
... f.writelines(['template = inline:something different'])
>>> run_buildout()
Uninstalling template.
Installing template.
The template install returned None. A path or iterable os paths should be returned.
Even though we used a different template, the file still contain the first template::
>>> cat('rendered')
initial content
slapos/recipe/template/jinja2_template.py
View file @
1d6b316c
...
...
@@ -266,7 +266,7 @@ class Recipe(object):
finally
:
os
.
close
(
fd
)
if
self
.
once
:
open
(
self
.
once
,
'
w
b'
).
close
()
open
(
self
.
once
,
'
a
b'
).
close
()
return
return
self
.
rendered
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment