Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Document how to make relative work with partials #60

Merged
merged 1 commit into from

2 participants

@ge0ffrey

No description provided.

@ge0ffrey

This partial trick is used by hibernate.org, optaplanner.org and maybe others.

@LightGuard LightGuard merged commit 1d7d848 into awestruct:master

1 check passed

Details default The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 26, 2014
  1. @ge0ffrey

    Update usage.md

    ge0ffrey authored
This page is out of date. Refresh to see the latest.
Showing with 16 additions and 0 deletions.
  1. +16 −0 extensions/relative/usage.md
View
16 extensions/relative/usage.md
@@ -28,3 +28,19 @@ And for `/one/two/three.html` this will result in:
Of course, it works on all kinds of URL usages:
%link{:rel => "shortcut icon", :href => relative("/favicon.ico")}
+
+---
+
+To make it work properly in partials, you need to pass along the outputPage to every partial and to the relative function:
+
+The outputPage `blogAggregation.html.haml` passes itself:
+
+ = partial('blogPostBody.html.haml', :outputPage => page, ...)
+
+to the partial `blogPostBody.html.haml`, which passes that outputPage:
+
+ = partial('userBadge.html.haml', :outputPage => page.outputPage, ...)
+
+to the partial `userBadge.html.haml`, which passes it to the relative call:
+
+ %img{:src => relative("/common/twitterLogo.png", page.outputPage)}
Something went wrong with that request. Please try again.