Coder Social home page Coder Social logo

helpfulrobot / svandragt-silverstripe-svdrequirements Goto Github PK

View Code? Open in Web Editor NEW

This project forked from svandragt/silverstripe-svdrequirements

0.0 2.0 0.0 15 KB

Combined requirements per page class extendable by modules

License: BSD 3-Clause "New" or "Revised" License

PHP 100.00%

svandragt-silverstripe-svdrequirements's Introduction

SvdRequirements

This is a convenience module enforcing best practices for using Requirements.

Features:

  • Combine a mixed list of JS / CSS assets using a single method.
  • Access to the $this->theme_dir variable in your page controllers.

SvdRequirements will seperate the js from the css files, and combine them for each controller.

Usage:

  1. Install using composer: composer require "svandragt/silverstripe-svdrequirements:*"

Example: you might have a Page and HomePage extends Page class, each with dozen JS and CSS requirements. Add SvdRequirements::combine($assets); to each init method.

Done!

In our example the site will now have the following files:

page_controller.css
homepage_controller.css
page_controller.js
homepage_controller.js

Quick access to theme folder

This optional SvdRequirementsExtension (enabled by default) adds a shortcut to the theme folder by setting a $theme_dir property to the Page_controller which you can access through $this->theme_dir - which would return 'themes/simple' for example.

You can convert the simple theme to use requirements in 2 steps:

  1. Remove all calls to CSS and JS from the templates.
  2. to the Page's init() method add the following code:
$assets = array(
	"{$this->theme_dir}/css/reset.css",
	"{$this->theme_dir}/css/layout.css",
	"{$this->theme_dir}/css/typography.css",
	"{$this->theme_dir}/css/form.css",
	"{$this->theme_dir}/javscript/script.js",
);
SvdRequirements::combine($assets);

I keep a list of known bugs.

svandragt-silverstripe-svdrequirements's People

Contributors

svandragt avatar

Watchers

James Cloos avatar helpfulrobot 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.