Skip to content

Feature: Attach baseurl property to template context#92

Merged
erikjung merged 3 commits intomasterfrom
feat-baseurl
May 19, 2016
Merged

Feature: Attach baseurl property to template context#92
erikjung merged 3 commits intomasterfrom
feat-baseurl

Conversation

@erikjung
Copy link
Contributor

Re: #63, cloudfour/drizzle#43

This change makes the {{baseurl}} template property have a value.

The value will be different depending on the location of each page, and will always be a relative path string pointing to the destination root directory (e.g. dist).

For example:

<!-- src/pages/index.hbs -->
<script src="{{baseurl}}/main.js">
<!-- dist/index.html -->
<script src="./main.js">
<!-- src/pages/sandbox/demos/navigation.hbs -->
<script src="{{baseurl}}/main.js">
<!-- dist/sandbox/demos/navigation.html -->
<script src="../../main.js">

This will allow the static HTML output to be viewed using the file:// protocol without needing any server:

screen shot 2016-05-19 at 3 48 26 pm

/CC @tylersticka @saralohr @nicolemors @aileenjeffries

@tylersticka
Copy link
Member

This sounds a lot more difficult than the code makes it look!

import path from 'path';
import { pathSatisfies, is } from 'ramda';

function getBaseUrl (resource, drizzleData) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance we can get documentation? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sigh. Fine.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:trollface:

@gerardo-rodriguez
Copy link
Member

Looks good @erikjung! Yes, it does sound difficult. :) Do we need to worry about writing any test for this at all?

Otherwise, LGTM! 👍

@erikjung erikjung merged commit 0803068 into master May 19, 2016
@erikjung erikjung deleted the feat-baseurl branch May 19, 2016 23:25
@erikjung
Copy link
Contributor Author

@mrgerardorodriguez

Do we need to worry about writing any test for this at all?

I realized that I didn't acknowledge this. Yes, there should eventually.

#93

The tests are going to get a big refactor soon.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants