Skip to content

Commit

Permalink
css(), js(), img() helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
igaster committed Feb 26, 2015
1 parent 068606a commit 75fec7b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ That's it. You are now ready to start theming your applications!

## Defining themes

Simple define your themes in the `themes` array in `config\theme.php`. The format every theme is very simple:
Simple define your themes in the `themes` array in `config\theme.php`. The format for every theme is very simple:

```php
// Select a name for your theme
Expand Down Expand Up @@ -101,7 +101,13 @@ The path is relative to Theme Folder (NOT to pubic!). For example, if you have p

When you are refering to a local file it will be looked-up in the current theme hierarcy, and the correct path will be returned. If the file is not found on the current theme or its parents then an exception will be thrown.

## Assets Managment (by Orchestra/ASset)
Some usefull helpers you can use:

Theme::js('file-name')
Theme::css('file-name')
Theme::img('src','alt', 'class-name')

## Assets Managment on steroids (by Orchestra/ASset)

This package provides intergration with [Orchestra/Asset](http://orchestraplatform.com/docs/3.0/components/asset) component. All the features are explained in the official documentation. Although Orchestra/Asset is installed along with this package, it's use is optional.

Expand All @@ -114,7 +120,7 @@ and add the Asset facade in your `Facades` array in `app/config/app.php`

'Asset' => 'Orchestra\Support\Facades\Asset',

Now you can leverage all the power of Orchestra\Asset package. However the syntax can become painful when you are using Themes + Orchestra/Asset, so some Blade-specific sugar has been added to ease your work. So here how to build your views:
Now you can leverage all the power of Orchestra\Asset package. However the syntax can become quite cumbersome when you are using Themes + Orchestra/Asset, so some Blade-specific sugar has been added to ease your work. Here how to build your views:

In any blade file when you need to refer to a script or css: (dont use single/double quotes)

Expand All @@ -130,7 +136,7 @@ exactly where you want write your declerations (usualy on Head and Footer of the

## Assets dependencies

Well this is an [Orchestra/Asset](http://orchestraplatform.com/docs/3.0/components/asset) feature explained well in the official documentation. Long story short:
This is an [Orchestra/Asset](http://orchestraplatform.com/docs/3.0/components/asset) feature explained well in the official documentation. Long story short:

@css (filename, alias, depends-on)
@js (filename, alias, depends-on)
Expand Down
14 changes: 14 additions & 0 deletions src/Themes.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,18 @@ public function set($themeName){
public function url($url){
return $this->activeTheme->url($url);
}

// Helper Functions (for Blade files)

public function css($href){
return '<link media="all" type="text/css" rel="stylesheet" href="'.$this->url($href).'">'."\n";
}

public function js($href){
return '<script src="'.$this->url($href).'"></script>'."\n";
}

public function img($src, $alt='', $Class=''){
return '<img src="'.$this->url($src).'" alt="'.$alt.'" class="'.$Class.'">'."\n";
}
}

0 comments on commit 75fec7b

Please sign in to comment.