Skip to content
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

Ability to override Component partials (Cherry pick method II) #44

Closed
daftspunk opened this issue May 10, 2014 · 2 comments
Closed

Ability to override Component partials (Cherry pick method II) #44

daftspunk opened this issue May 10, 2014 · 2 comments

Comments

@daftspunk
Copy link
Member

The current solution (#41) is a bit flakey. After some careful consideration, the following approach should be used instead.


Components referencing partials

Components can reference their partials in two ways. First is an explicit method:

{% partial __SELF__ ~ "::title" %}

The second is a relaxed method:

{% partial "@title" %}

The relaxed method is contextual:

  1. If called inside a component partial, it will directly refer to itself.
  2. If called inside a theme partial, it will scan all components used on the page/layout for a matching partial name and use that. Then will continue as per 1. for nested partials.

Overriding component partials

All component partials can be overridden using the theme partials. Following from the previous example, if our component called channel uses the title.htm partial.

url = "mypage"

[channel]
==
{% component "channel" %}

We can override the partial by creating a file in our theme called partials/channel/title.htm.

The file path is broken down like this:

  • partials - the theme partials directory
  • channel - the component alias (a partial subdirectory)
  • title.htm - the component partial to override

We can choose our own name for the partial subdirectory by giving the component a different alias. For example:

[channel foobar]
==
{% component "foobar" %}

Now we can override the partial by creating a file in our theme called partials/foobar/title.htm.

@daftspunk
Copy link
Member Author

This has been implemented in the latest build

@drFabio
Copy link

drFabio commented Apr 2, 2015

Quick doubt. This would work with the default.htm partial as well? i don't seem to be getting to override the blog plugin, posts component default.htm with that approach

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants