0
I Use This!
Activity Not Available

Project Summary

Fast and simple template system similar to Mako or Jinja (python template engines). Project is still in planning stage, first usable release is expected within a month.

As a template language, Savy aims to be minimal and consistent. It has simple syntax, similar to Python, and compiles to straight PHP code. It is not too smart for its own good (pun intended, Smarty is an abomination).

(The rest of this page should go to Syntax page)

SyntaxDecorators (Sigils)All template variables (aka tags) are prefixed with $ Savy directives/keywords start with %. All block level constructs end with %end directive.

You can have a standard PHP block '' inside template. This can be disabled before compiling a template, so you can have "safe" templates, whatever that means. Also, inside templates, you can't assign values to (PHP) variables (except from a PHP block).

Library has two parts, template compiler, and template class/loader. (Pre)compiled templates can be saved/loaded from filesystem, or can be executed on the fly (using eval())

Template variables$VarName - short form
${VarName} - full form
${VarName|filter|filter2} - full form, with filtersFilters can only be simple PHP functions, taking one string parameter and returning string. Without side effects if possible. No stupid $Templage->assign('variable_name', 'value') either, variables are injected from PHP directly (standard PHP scoping rules apply, similar to include/require).

When compiled, above examples look like this.

$VarName ->
${VarName|f|g} -> Running PHP snippet:

${title|strtoupper}'));
?>would output

HELLO WORLDLoopsfor%for $i in 0..$max_count:
...
%endCompiled form:

...
foreachIterating through dictionary:

%for $key, $data in $List:
$data
%end
Compiled form:

$data): ?>


Branching%if CondList:
...Some text/HTML...
%elif CondList:
...Alternative 1...
%else
...Catch all...
%endIncluding (sub)templates:

%include path/to/template
or
%include $pathEquivalent to PHP's include and require, but relative paths use current template as a base (no include_path problems and similar). You can use full path though:

%include /full/path/to/file
%include "$PREFIX/sub/path/to/file"You don't have to enclose paths in "".

Meta programmingMacrosVery basic macro subsystem, a macro call is substituted with expanded macro body, formal parameters are replaced with real arguments. I'd really like a macro system in PHP as well, but that's not going to happen.

%macro dropdown_list($list, $style)
%if $style:

%else

%end

%for $key, $data in $list:
$data
%end


%endand called from some template:

'one', 2=>'two', 3=>'three');

eval(savy::render('%call dropdown_list($items, "green")'));outputs

one
two
three
Note that you can make macros pretty powerful, since one can use PHP blocks inside them:

%macro tryme($var)

%endTODO:

Complex variables/tags (arrays). Named blocks; template inheritance (Jinja):

%block BlockName
...
%end

Tags

No tags have been added

In a Nutshell, savy...

 No code available to analyze

Open Hub computes statistics on FOSS projects by examining source code and commit history in source code management systems. This project has no code locations, and so Open Hub cannot perform this analysis

Is this project's source code hosted in a publicly available repository? Do you know the URL? If you do, click the button below and tell us so that Open Hub can generate statistics! It's fast and easy - try it and see!

Add a code location

GNU General Public License v3.0 or later
Permitted

Commercial Use

Modify

Distribute

Place Warranty

Use Patent Claims

Forbidden

Sub-License

Hold Liable

Required

Distribute Original

Disclose Source

Include Copyright

State Changes

Include License

Include Install Instructions

These details are provided for information only. No information here is legal advice and should not be used as such.

This Project has No vulnerabilities Reported Against it

Did You Know...

  • ...
    in 2016, 47% of companies did not have formal process in place to track OS code
  • ...
    anyone with an Open Hub account can update a project's tags
  • ...
    65% of companies leverage OSS to speed application development in 2016
  • ...
    search using multiple tags to find exactly what you need

 No code available to analyze

Open Hub computes statistics on FOSS projects by examining source code and commit history in source code management systems. This project has no code locations, and so Open Hub cannot perform this analysis

Is this project's source code hosted in a publicly available repository? Do you know the URL? If you do, click the button below and tell us so that Open Hub can generate statistics! It's fast and easy - try it and see!

Add a code location

Community Rating

Be the first to rate this project
Click to add your rating
   Spinner
Review this Project!
Sample ohloh analysis