Coder Social home page Coder Social logo

less.php's Introduction

less.php

The dynamic stylesheet language.

http://lesscss.org

about

This is a PHP port of the official JavaScript version of LESS http://lesscss.org.

Most of the code structure remains the same, which should allow for fairly easy updates in the future. That does mean this library requires PHP5.3 as it makes heavy use of namespaces, anonymous functions and the shorthand ternary operator - ?: (to replicate the way Javascript will return the value of the first valid operand when using ||).

A couple of things have been omitted from this initial version:

  • Evaluation of JavaScript expressions within back-ticks (for obvious reasons).
  • Definition of custom functions - will be added to the \Less\Environment class.
  • A tidy up of the API is needed.

use

The parser

<?php

$parser = new \Less\Parser();
$parser->getEnvironment()->setCompress(true);

// parse css from a less source file or directly from a string
$css = $parser
            ->parseFile($path)
            ->parse("@color: #4D926F; #header { color: @color; } h2 { color: @color; }")
            ->getCss();

The command line tool

The bin/lessc command line tool will accept an input (and optionally an output) file name to process.

$ ./bin/lessc input.less output.css

In your website

The bin/less.php file can be moved to the directory containing your less source files. Including a links as follows will compile and cache the css.

<link rel="stylesheet" type="text/css" href="/static/less/css.php?bootstrap.less" />

NB: You'll need to update this file to point to the lib directory, and also make sure the ./cache directory is writable by the web server.

license

See LICENSE file.

less.php's People

Contributors

agar avatar mordred avatar

Stargazers

 avatar

Watchers

 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.