-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Expose basename
from document.rb
as name
to Liquid templates
#8761
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
Expose basename
from document.rb
as name
to Liquid templates
#8761
Conversation
Expose `basename` method as `name` in Liquid, so `{{ page.name }}` works in posts.
Add `basename` method to `excerpt` class.
basename
from document.rb
as name
Liquid (document_drop.rb
), enabling {{ page.name }} in posts/pages
@jjnilton This needs a test coverage as well. |
@ashmaroli sorry for taking so long to reply here. I think I will need some help with the tests. I searched the code to find some test examples with the My thinking was that |
basename
from document.rb
as name
Liquid (document_drop.rb
), enabling {{ page.name }} in posts/pagesbasename
from document.rb
as name
to Liquid templates
@jjnilton First of all Hope I was able to clear that fog. Regarding tests, since you are only improving exposed Liquid attributes for documents (also posts), the best location to add a test would be in |
ping @jjnilton |
@ashmaroli sorry for taking so long to reply (again), and thanks for the explanations.
I changed the # The base filename of the excerpt.
#
# Returns the base filename for the doc this excerpt belongs.
def basename
@basename ||= File.join(doc.basename, "#excerpt")
end And it does not return the Adding to delegate_methods :id, :output, :content, :to_s, :relative_path, :url, :date, :basename If I don't use
I think that I've slowed down this fix, so if you or someone else want continue, please do. Maybe it'll help me understand how it should be done. |
I've left a suggestion in the review. Plus, if you don't wish to continue working on this, feel free to close this PR. |
Updated with the suggestion but it throws that error during the tests:
There are other failures too, but it seems they appear even on a fresh clone from |
…pose-basename-as-name-liquid
My bad! I did not notice that you added the definition to |
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.
LGTM!
Thanks @jjnilton |
JJ: Expose `basename` from `document.rb` as `name` to Liquid templates (#8761) Merge pull request 8761
Summary
Expose
basename
method fromdocument.rb
asname
in Liquid (document_drop.rb
),and addbasename
method toexcerpt.rb
, preventing error/failure in test.Context
Fixes #8699.