GithubHelp home page GithubHelp logo

laravel-theme's Introduction

Simple theme support for Laravel 4

Inspired by lightgear/theme, but not depend on specific asset manager.

Install

Composer require:

"bigecko/laravel-theme": "dev-master"

Service provider:

'Bigecko\LaravelTheme\LaravelThemeServiceProvider',

Alias:

'Theme' => 'Bigecko\LaravelTheme\Facade',

Usage

Structure

├── public/
    └── themes/
        ├── mytheme/
        |   ├── js/
        |   ├── css/
        |   └── views/
        |
        └── anothertheme/

Create a new folder public/themes.

Create a folder in themes use your theme name, like mytheme.

Put your theme templates file to mytheme/views.

init theme

Theme::init('mytheme');

custom path

Theme::init('mytheme', array(
    'public_dirname' => 'allthemes',    // Base dirname for contain all themes, relative to public path.
    'views_path' => app_path('views'),  // Change the path to contain theme templates.
));

Once you change the views_path, the sub dir views for theme is not needed,
just create your theme folder in views_path, and put templates in it.
like: app/views/mytheme/hello.blade.php.

Code example

View::make('home');  // First find in 'public/themes/mytheme/views/'.
                     // If file not exist, will use default location 'app/views/'.


Theme::asset('js/a.js');  // 'http://domain/themes/mytheme/js/a.js'

Theme::publicPath('js/jquery.js')  // /path/to/project/public/themes/mytheme/js/jquery.js

Theme::name(); // Get current theme name.

Also support package templates overriding, just put package templates to your theme views folder.

Why use this?

Simple:

  • Dot not need change code to render template, still View::make.
  • No asset management or other dependencies.
  • No new config file.
  • Just few lines of code, easy to read.
  • Only for theme, no more other responsibilities.

TODO

  • Add unit testing.

laravel-theme's People

Contributors

harryxu avatar

Watchers

James Cloos avatar arissan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.