-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Filter _Template content. Resolves #1603 and #1640. #1612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I like the way this works on the user side, and the customizability! See comment. |
… to easily add _Template Filters.
I processed your comments and used your API proposal for the new version. Filters can now be added in Gollum::TemplateFilter.add_filter('{{current_date}}') do
Time.now.strftime("%d/%m/%Y")
end
Gollum::TemplateFilter.add_filter('{{current_time}}') do
Time.now.strftime("%T")
end |
Very cool! Looks super elegant now. |
I think this is a nifty feature, yes, and the implementation is nice and clean -- so by all means! |
Can't wait for the release! |
Found no document about this nifty feature, I just documented it with an example here: https://github.com/gollum/gollum/wiki/Home/_compare/257834c879687ac819a0993019acdedca60c0e48 @bartkamphorst @dometto PTAL as I barely understand the difference between a proc and a block, the example works, but I'm not sure if it's the best practice. Thanks for the work! |
@bartkamphorst This may sound straightforward to you: is it possible to access |
@@ -639,6 +636,11 @@ def show_file(file) | |||
end | |||
end | |||
|
|||
def load_template(path) | |||
template_page = wiki_page(::File.join(path, '_Template')).page || wiki_page('/_Template').page | |||
template_page ? Gollum::TemplateFilter.apply_filters(template_page.raw_data) : nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bartkamphorst @dometto How about passing path
to apply_filters
so that it could be accessed in the replacement
?
This makes a filter like {{page_name}}
possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me, if you're wiling to open a PR for this @tevino! What do you think @bartkamphorst?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the documentation @tevino! |
This is a proposed solution to the question in #1603 . Basically, we just allow users to create a
Gollum::TemplateFilter
in theirconfig.rb
and let them manipulate the contents of_Template
however they want at runtime. What do you think about this approach @dometto? A very simple example of such a filter could be the following:(Where
_Template.md
would obviously need to include something likeDate: {{current_date}}
.)