-
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mako): can now use custom libraries in pycode
Namespaces can exclusively be used during rendering, which is fine if you remind yourself of the newline rules. However, I also need some utiltiies that convert input data. These are now within their own libraries, which can be used from python blocks like the ordinary python functions they are. Quite neat. In future, most of the functionality will be in separate namespaces, the top-level will just assemble the main library file, usnig the provided %defs. That way, the main file is kept clean.
- Loading branch information
Showing
7 changed files
with
33 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.pyenv | ||
*.pyc | ||
generated/ | ||
target | ||
.api.deps | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
|
||
|
||
## This will only work within a substitution, not within python code | ||
<%def name="to_api_version(v)">\ | ||
<% assert len(v) >= 2 and v[0] == 'v'%>\ | ||
## convert it once to int, just to be sure it is an int | ||
${v[1:]}\ | ||
</%def> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
def to_api_version(v): | ||
assert len(v) >= 2 and v[0] == 'v' | ||
return v[1:] |