2017 © Pedro Peláez
 

extension scripter

image

dipcms/scripter

  • Friday, September 30, 2016
  • by mykola.chomenko
  • Repository
  • 0 Watchers
  • 1 Stars
  • 29 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Scripter for Nette Framework

Scripter allows you to load CSS and JavaScript files for Nette Framework., (*1)

Installation

The best way to install DIPcms/Scripter is using Composer:, (*2)

$ composer require dipcms/scripter

Minimal configuration

extensions:
    scripter: DIPcms\Scripter\DI\ScripterExtension

Settings

#Default settings
scripter:
    temp_dir: %tempDir% 
    url_path_name: 'getsource'
    default_syntax: 'asp' #synatxe: latte, double, asp, python, off

Rendering CSS and JS

Rendering is performed by Nette Latte (template engine) Macros are written with the help of ASP tags. It depends on the settings. You can also use:, (*3)

  • latte: { ... }
  • double: {{ ... }}
  • asp: <% ... %>
  • python: {% ... %} and {{ ... }}

Details on how you can find syntax, (*4)

Macros

  • <%file "font.ttf"%> Save the file to cahce and creates a link to the file.
  • <%img "images.jpg"%> Save the image to cahce and creates a link to the image.

Default macro can be found Latte, (*5)

Functionality

Adding Parameters to file, (*6)

   # use DIPcms\Scripter\Scripter;

   $scripter->parameter_name = "value"; 

Add file, (*7)

   # use DIPcms\Scripter\Scripter;

   $scripter->addFile(__DIR__ . "/style.css"); 

Use

Create css file style.css, (*8)

    body{
        background: <%img "bg.jpg"%>;
        width: <%$width%>px;
    }

Your application, (*9)

    namespace App\Presenters;

    use Nette;
    use DIPcms\Scripter\Scripter;

    class HomepagePresenter extends Nette\Application\UI\Presenter{

        /**
        * @var Scripter @inject
        */
        public $scripter;

        public function renderDefault(){
            $this->scripter->width = 50;
            $this->scripter->addFile(__DIR__.'/style.css');
        }
    }

Scripter automatically add a link in the header to the CSS and JS file., (*10)

    <head>
    <meta charset="utf-8">  
        #............
        <script type="text/javascript" src="/getsource/6666cd76f96956469e7be39d750cc7d9/js"></script>
        <link rel="stylesheet" href="/getsource/6666cd76f96956469e7be39d750cc7d9/css">
    </head>

The Versions