silverstripe-framework: `ViewableData::ThemeDir()` broken

Acceptance Criteria

  • $ThemeDir is restored to templates
  • The value of ThemeDir depends on the template it is being used within
  • The value will the root-relative URL (i.e. starts with “/”) of the theme folder, as processed by ResourceURLGenerator.
  • A template string such as <img src="$ThemeDir/images/something.png"> will reference images/something.png within the theme.

Exclusions:

  • Direct access to ThemeDir from ViewableData isn’t necessary (so it can be implemented as a template global instead if preferred)

$ThemeDir is used in templates to pull in assets. This is currently used by https://github.com/silverstripe-themes/silverstripe-simple to pull in a JS file.

However this is now broken after moving to cascading themes.

PRs

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 25 (24 by maintainers)

Most upvoted comments

I’ve drafted some ACs above — can @chillu and @tractorcow 👍 them?

$ThemeDir seems like a frequently used API, so let’s fix this in 4.0.1 (as opposed to 4.1.0) - assigning milestone.