Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an example ITemplateHelpers extension
- Loading branch information
Showing
4 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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,28 @@ | ||
import ckan.plugins as plugins | ||
|
||
|
||
class ExampleITemplateHelpersPlugin(plugins.SingletonPlugin): | ||
'''An example that shows how to use the ITemplateHelpers plugin interface. | ||
''' | ||
plugins.implements(plugins.IConfigurer) | ||
plugins.implements(plugins.ITemplateHelpers) | ||
|
||
# Update CKAN's config settings, see the IConfigurer plugin interface. | ||
def update_config(self, config): | ||
|
||
# Tell CKAN to use the template files in | ||
# ckanext/example_itemplatehelpers/templates. | ||
plugins.toolkit.add_template_directory(config, 'templates') | ||
|
||
# Our custom template helper method. | ||
def example_helper(self): | ||
'''An example template helper method.''' | ||
|
||
# Just return some example text. | ||
return 'This is some example text.' | ||
|
||
# Tell CKAN what custom template helper methods this plugin provides, | ||
# see the ITemplateHelpers plugin interface. | ||
def get_helpers(self): | ||
return {'example_helper': self.example_helper} |
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,6 @@ | ||
{% ckan_extends %} | ||
|
||
{% block secondary_content %} | ||
{{ super() }} | ||
{{ h.example_helper() }} | ||
{% endblock %} |
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