Expose basename from document.rb as name to Liquid templates#8761
Expose basename from document.rb as name to Liquid templates#8761jekyllbot merged 8 commits intojekyll:masterfrom jjnilton:expose-basename-as-name-liquid
basename from document.rb as name to Liquid templates#8761Conversation
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")
endAnd it does not return the Adding to delegate_methods :id, :output, :content, :to_s, :relative_path, :url, :date, :basenameIf 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 |
|
Thanks @jjnilton |
JJ: Expose `basename` from `document.rb` as `name` to Liquid templates (#8761) Merge pull request 8761
Summary
Expose
basenamemethod fromdocument.rbasnamein Liquid (document_drop.rb),and addbasenamemethod toexcerpt.rb, preventing error/failure in test.Context
Fixes #8699.