Coder Social home page Coder Social logo

yii2-prototype-module's Introduction

Yii2 Prototype Module

Latest Stable Version Total Downloads License

Twig, LESS and HTML Content prototyping module for Yii 2.0 Framework

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist dmstr/yii2-prototype-module "*"

or add

"dmstr/yii2-prototype-module": "*"

to the require section of your composer.json file.

Requirements

  • configured Twig view renderer in application (since 0.5.0-rc6)

Usage

####Prototype command:

#####Configuration

In your console config add:

'controllerMap' => [
    'prototype' => 'dmstr\modules\prototype\commands'
]
Commands:
  • prototype/export-html
  • prototype/export-less
  • prototype/export-twig

Each of these commands exports either html, less or twig as a file on a given file path (via --exportPath flag) default is @runtime/exports

Note: To escape file names you can use the --escapeFileNames flag

  • prototype/export-asset-bundle <mainLessFile (optional)>

Exports less files and an asset bunde to a given export path (via --exportPath flag) default is @runtime/exports

Note:

1.) You will be prompted to choose a namespace and to select less files which should be added to the asset bundle 2.) The defined main less file will be automatical have default yes in confirmation

--> if you run this command on non interactive mode (--interactive=0), main less file will be added to the asset bundle and the namespace will be set to app\assets

Twig example

{{ use ('hrzg/moxiecode/moxiemanager/widgets') }}

{{ browse_button_widget( {"tagName": "a"} ) }}

Cache trigger time

\Yii::$app->cache->get('prototype.less.changed_at');

Testing

docker-compose up -d

docker-compose run phpfpm codecept run

CRUDS

‼️ Do no regenerate CRUDs for html

$ yii batch \
    --tables=app_twig \
    --modelNamespace=dmstr\\modules\\prototype\\models \
    --modelQueryNamespace=dmstr\\modules\\prototype\\models\\query \
    --crudSearchModelNamespace=dmstr\\modules\\prototype\\models\\query \
    --crudControllerNamespace=dmstr\\modules\\prototype\\controllers \
    --crudViewPath=@dmstr/modules/prototype/views \

yii2-prototype-module's People

Contributors

eluhr avatar gbisurgi avatar handcode avatar schmunk42 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

yii2-prototype-module's Issues

Make twigs available as file

By using the key under a certain alias, like:

@twig/my-triple.twig     
@twig/my-triple.db-twig

Requires a CLI command to write files to disk.

Access for non-Editor users

Hi. Maybe I have misunderstood something but it seems that the HtmlWidget renders the content just when the user have the 'Editor' role (which has 'Pages Module', 'Main Site Controller' and 'Backend Dashboard' permissions).

const ACCESS_ROLE = 'Editor';
...
 if (\Yii::$app->user->can(self::ACCESS_ROLE)) {

Shouldn't this code:

if (!$model) {
    $html = $this->renderEmpty();
} else {
    $html = $model->value;
}

be out of the user->can(self::ACCESS_ROLE) check?

Otherwise I don't have clear how to use the module to make pages publicly available.

Editor lives own life

Hello. A little question about editor. Is there any way to get back an old one? Because new one is not working properly. I am trying to edit one of my template, I need to add this html code

<barcode code="Your message here" size="0.8" type="QR" error="M" class="barcode" />

I am doing it on source tab, I'm adding it, clicking save. It's in database, but It vanishes from editor when I am trying to edit it again, editor just hides this line even if I wrap it with div tags.

Found allowedContent attribute to disable filtration, but this code not work

<?= $form->field($model, 'value')->widget(CKEditor::className(), [
                'options' => ['height' => '400', 'allowedContent' => true ],
                'preset' => 'full',
            ]) ?>

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.