Download the PHP package opine/lightncandy without Composer

On this page you can find all versions of the php package opine/lightncandy. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package lightncandy

LightnCandy

An extremely fast PHP implementation of handlebars ( http://handlebarsjs.com/ ) and mustache ( http://mustache.github.io/ ).

Travis CI status: Unit testing Regression testing

Scrutinizer CI status: Code Coverage

Package on packagist: Latest Stable Version License HHVM Status

Features

Installation

Use Composer ( https://getcomposer.org/ ) to install LightnCandy:

Or, download LightnCandy from github:

LightnCandy requirement: PHP 5.3.0+ .

UPGRADE NOTICE

Usage

The output will be:

Compile Options

You can apply more options by running LightnCandy::compile($template, $options):

Default is to compile the template as PHP, which can be run as fast as possible (flags = FLAG_BESTPERFORMANCE).

Partial Support

LightnCandy supports partial when compile time. You can provide partials by partials option when compile():

You can also provide partials by files. When compile(), LightnCandy will search template files from basedir in the option if you provided one or more. Default template file name is *.tmpl, you can change or add more template file extensions with fileext option.

With this setting, when you include a partial by {{> partial_name}}, LightnCandy will search in this order:

By default, partial uses the same context with original template. If you want to change context for the partial, you may add one more argument after the partial name:

Custom Helper

Custom helper can help you deal with common template tasks, for example: provide URL and text then generate a link. To know more about custom helper, you can read original handlebars.js document here: http://handlebarsjs.com/expressions.html .

NOTICE: custom helpers to handle single tag {{xxx}} or a section {{#yyy}} ... {{/yyy}} are absolutely different in LightnCandy. To know more about creating custom helpers to handle {{#yyy}} ... {{/yyy}}, please refer to Block Custom Helper.

When compile(), LightnCandy will lookup helpers from generated custom helper name table. You can register custom helpers with helpers option (NOTICE: FLAG_NAMEDARG is required for named arguments, FLAG_ADVARNAME is required for string or subexpression arguments):

Custom Helper Interface

The input arguments are processed by LightnCandy automatically, you do not need to worry about variable name processing or current context. You can also use double quoted string as input:

Your custom helper function will be executed with two arguments. The first one is noname arguments, the second one is named arguments:

In your template:

Custom Helper Escaping

The return value of your custom helper should be a string. When your custom helper be executed from {{ }} , the return value will be HTML escaped. You may execute your helper by {{{ }}} , then the original helper return value will be outputted directly.

When you need to do different escaping logic, you can return extended information by Array($responseString, $escape_flag) , here are some custom helper return value cases:

Block Custom Helper

Block custom helper must be used as a section, the section is started with {{#helper_name ...}} and ended with {{/helper_name}}.

You may use block custom helper to:

  1. Provide advanced condition logic which is different from {{#if ...}} ... {{/if}} .
  2. Modify current context for the inner block.
  3. Provide different context to the inner block.

You can register block custom helpers with blockhelpers option:

Block Custom Helper Interface

LightnCandy handled all input arguments for you, you will receive current context and parsed arguments. The return value of helper function will become new context then be passed into inner block. If you do not return any value, or return null, the inner block will not be rendered. For example:

You cannot provide new rendered result, nor handle loop in your block custom helper. To provide different rendering result, you should use custom helper. To handle loop, you should use {{#each}} . For example:

The mission of a block custom helper is only focus on providing different context or logic to inner block, nothing else.

Handlebars.js' Custom Helper

You can implement helpers more like Handlebars.js way with hbhelpers option, all matched single custom helper and block custom helper will be handled. In Handlebars.js, a block custom helper can rendener child block by executing options->fn, and change context by send new context as first parameter. Here are some examples to explain the behavior of hbhelpers custom helper:

#mywith (context change)

#myeach (context change)

#myif (no context change)

Hashed arguments

Escaping

When a Handlebars.js style custom helper be used as block tags, LightnCandy will not escape the result. When it is a single {{...}} tag, LightnCandy will escape the result. To change the escape behavior, you can return extended information by Array(), please read Custom Helper Escaping for more.

Template Debugging

When template error happened, LightnCandy::compile() will return false. You may compile with FLAG_ERROR_LOG to see more error message, or compile with FLAG_ERROR_EXCEPTION to catch the exception.

You may generate debug version of templates with FLAG_RENDER_DEBUG when compile() . The debug template contained more debug information and slower (TBD: performance result) , you may pass extra LCRun3 options into render function to know more rendering error (missing data). For example:

The ANSI output will be:

Here are the list of LCRun3 debug options for render function:

Unsupported Feature (so far)

Suggested Handlebars Template Practices

Detail Feature list

Go http://handlebarsjs.com/ to see more feature description about handlebars.js. All features align with it.


All versions of lightncandy with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package opine/lightncandy contains the following files

Loading the files please wait ....