-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(native): Python - new Jinja API (#7160)
- Loading branch information
Showing
6 changed files
with
399 additions
and
51 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
30 changes: 30 additions & 0 deletions
30
packages/cubejs-backend-native/python/cube/src/__init__.py
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,3 +1,33 @@ | ||
class JinjaException(Exception): | ||
pass | ||
|
||
class JinjaContext: | ||
def function(self, func): | ||
if not callable(func): | ||
raise JinjaException("function registration must be used with functions, actual: '%s'" % type(func).__name__) | ||
|
||
return context_func(func) | ||
|
||
def filter(self, func): | ||
if not callable(func): | ||
raise JinjaException("function registration must be used with functions, actual: '%s'" % type(func).__name__) | ||
|
||
raise JinjaException("filter registration is not supported") | ||
|
||
def variable(self, func): | ||
raise JinjaException("variable registration is not supported") | ||
|
||
class TemplateModule: | ||
def JinjaContext(): | ||
return JinjaContext() | ||
|
||
template = TemplateModule | ||
|
||
def context_func(func): | ||
func.cube_context_func = True | ||
return func | ||
|
||
__all__ = [ | ||
'context_func', | ||
'template' | ||
] |
Oops, something went wrong.