Giter VIP home page Giter VIP logo

smartybundle's People

Contributors

davidfuhr avatar eufrost avatar gitter-badger avatar igor-vovk avatar im-bravo avatar maoueh avatar naucon avatar pchol avatar pjparra avatar vitorbrandao avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

smartybundle's Issues

"Unable to render the form as none of the following blocks exist"

Hello, i generated a crud scripts and stuff with

php app/console generate:doctrine:crud

php is

    public function newAction()
    {
        $entity = new User();
        $form   = $this->createForm(new UserType(), $entity);
        return $this->render('WMainBundle:AdminUser:new.html.smarty', array(
            'entity' => $entity,
            'form'   => $form->createView(),
        ));

    }

in template there is

{extends 'file:[WMainBundle]/Admin/layout__type_crud.html.smarty'}

{block header}
User, добавление
{/block}

{block main}
    <form action="{path subcontroller='user' subaction='create'}w_admin{/path}" method="post" {form_enctype form=$form}>
        {form_widget form=$form}
        <p>
            <button type="submit">Добавить</button>
        </p>
    </form>
{/block}

{block operations}
        <ul class="nav nav-pills">
    <li>
        <a href="{path subcontroller='user'}w_admin{/path}">
            Назад к списку
        </a>
    </li>
</ul>
{/block}

However, i get the

Unable to render the form as none of the following blocks exist: "_w_mainbundle_usertype_enctype", "w_mainbundle_usertype_enctype", "form_enctype"

error

the big picture
image

what i should do?

Invalid format for plugins_dir

If I need to install a plugin directory, then Smarty ceases to see the default directory.
This is because the function setPluginsDir, through which there is a pass option plugins_dir

class Smarty extends Smarty_Internal_TemplateBase

    public function setPluginsDir($plugins_dir)
    {
        $this->plugins_dir = array();
        foreach ((array) $plugins_dir as $k => $v) {
            $this->plugins_dir[$k] = rtrim($v, '/\\') . DS;
        }

        return $this;
    }

erases the specified directory and sets new.

I think it would be good to give the ability to set an array plugins_dir

->arrayNode('plugins_dir')
    ->prototype('scalar')->end()
->end()
smarty:
    options:
        plugins_dir:
            - %kernel.root_dir%/../vendor/smarty/smarty/distribution/libs/plugins
            - %kernel.root_dir%/Resources/plugins

Using SmartyBundle with Silex

Is it possible to use SmartyBundle with Silex? And if so what would it take to connect to two together? There appears to be a few other people on Stackoverflow who have tried to do this before, but it doesn't sound like anyone has gotten it to work yet.

Undefined property using form_widget

In v2.1.3, an attempt to create a form using a Smarty template and the symfony form object, the line
{form_widget form=$form}
results in the following:
"Notice: Undefined property: NoiseLabs\Bundle\SmartyBundle\Extension\FormExtension::$resources in G:\Documents\workspace\sym\vendor\noiselabs\smarty-bundle\NoiseLabs\Bundle\SmartyBundle\Extension\FormExtension.php line 325" in "G:\Documents\workspace\sym\src\Mana\AdminBundle/Resources/views/Client/client_addnew.html.tpl"

Without the widget line the template appears as expected.

As an aside: I'm successfully using the default Smarty extension .tpl while in the Netbeans IDE.

Symfony3

Hey!

This package isn't allow installing for Symfony 3. But I think it should works.
Can you make it installable via composer for symfony3 ? :-)

Thanks!

Mopa Bootstrap a requirement?

Hi did an upgrade and when I try to run symfony console commands I always get

[InvalidArgumentException]                                                                                                                               
  Bundle "MopaBootstrapBundle" does not exist or it is not enabled. Maybe you forgot to add it in the registerBundles() method of your AppKernel.php file  
  ?         

which is correct it is not installed and I don't actually require it?
How do I turn this requirement off?
Thanks

Intergrate security module

Lets discuss how the plugins should look like

Suggestions to start from:

{if {is_granted role='IS_AUTHENTICATED_FULLY'}} // easy to understand but the extra {} is ugly. Params: role, roles, object, field

{if 'IS_AUTHENTICATED_FULLY'|is_granted} not great with $object and $field

$app also works ofc
{if $app->getSecurity()->isGranted('IS_AUTHENTICATED_FULLY')}

None of them is really great

What do you think ?

Cannot install

Hi,

could you please help me with the install?

I'm running "composer update noiselabs/smarty-bundle" and get an error:

Loading composer repositories with package information
Updating dependencies (including require-dev)

  • Installing smarty/smarty (v3.1.13)
    Checking out /tags/v3.1.13/@4699

    [RuntimeException]
    Package could not be downloaded, svn: Can't move '/media/sf_www/symf/vendor/smarty/smarty
    /.svn/tmp/entries' to '/media/sf_www/symf/vendor/smarty/smarty/.svn/entries': Operation not permitted

It looks to me that svn creates the files with wrong permissions, but currently I have no idea on how to fix that. Could you help me please?

Using of string resource creates ./template_c directory

If I don't use a file resource but render a template from the string, smarty creates template_c not in the var/cache/prod/smarty/template_c but in the current directory.
Minimal example:

<?php
namespace AppBundle\Tests\Controller;

use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

class TemplatingResourceTest extends WebTestCase
{
    public function testString()
    {
        $client = static::createClient();

        $smarty = $client->getContainer()->get('smarty');

        $template = $smarty->fetch('string:{assign var="var1" value="testValue"}{$var1}');

        $this->AssertFileNotExists('template_c');
    }
}

Running this will fail and will create template_c/ in the symfony root directory. Running similar code from the controller will create template_c/ in the web/ directory (so web/template_c).

What is the problem?
'compile_dir' is set in NoiseLabs\Bundle\SmartyBundle\DependencyInjection\Configuration and it happens in the constructor of NoiseLabs\Bundle\SmartyEngine. So if I call $this->get('smarty') before $this->render(...) in controller I get unconfigured smarty instance.
My suggestion would be to create a smarty service around the \Smarty and set smarty configuration inside of this service. If this solution is acceptable I can create a pull request.

Using {render} with URI

The latest implementation of actions extension tries to convert input field of {render} tag as a ControllerReference (irrespective of it being an URI or a controller name) in case of symfony > 2.1. This gives an exception in case URI is passed in the tag. Is tis an intended behavior or am I missing something. Any pointers will be very helpful

Forms and assetic

Hi,

do you have any idea when you will continue with building for the form and assetic extension ?

Update for Symfony 2.2

It would be nice to use it with Symfony 2.2. For the first sight, it would require only a few modifications. I will try to test it tomorrow and send a patch if I can make it to work.

Template Paths not added

I'm currently migrating a legacy app, it seems the config var "template_dir" is used for smarty, but not for the (symfony) template loader / locator, which makes it impossible to load a template.

template_dir configuration option only accepts a single scalar value

It is stated in documentation, that template_dir configuration value may as well be an array of paths, but actually only a single scalar value is accepted, so an InvalidTypeException with message "Invalid type for path "smarty.options.template_dir". Expected scalar, but got array." is thrown when trying to provide an array of paths.

Cannot update smarty to 3.1.30

In current stable version there is a restriction for smarty version "smarty/smarty": "3.1.*,<=3.1.27"
Would it be fixed soon ?

- Installing smarty/smarty (v3.1.13)

Hello I'm trying to install the bundle but I got allways the same error.

  • Installing smarty/smarty (v3.1.13)
    Checking out /tags/v3.1.13/@4699

    [RuntimeException]
    Package could not be downloaded, A /mnt/hgfs/gyg/gyg/vend....

I tried to install a new version of svn as I read in other sites a more diferents things. Could we delete the line:

  • "smarty/smarty": "3.1.*@stable"

    in SmartyBundle\Composer.lock and install "smarty" for other site, I mean without the bundle. Or what you could tell me for fix this error ?

Thanks a lot for your answer !

{render} tag doesn't work like it should

Hello,

im using {render menutype='mobile'}WebsiteBundle:Menu:list{/render}
Now im getting an error:
"MenuController::listAction()" requires that you provide a value for the "$menutype" argument (because there is no default value or because there is a non optional argument after this one)"

Between step 8 and 9 im losing the parameters.
"at ActionsHelper ->render ('WebsiteBundle:Menu:list', array(), array())

in ***/vendor/bundles/NoiseLabs/Bundle/SmartyBundle/Extension/ActionsExtension.php at line 80 -+
at ActionsExtension ->renderAction (array('menuype' => 'other'), 'WebsiteBundle:Menu:list', object(Smarty_Internal_Template), false) "

When I go to the bundles/NoiseLabs/Bundle/SmartyBundle/Extension/ActionsExtension.php at line 80
I see that attributes and options are merged with parameters and are set as an empty array.

The problem is that the listAction listen to those to.
A short 'fix' is to put 'attributes => $parameters

But that is not a nice fix. Do you known a better one ?

Symfony 5 support

@vitorbrandao Hi! Do you have plans to add sf5 support?
I faced some problems trying to adopt it for sf5.

  1. There is no tempting section in framework config, so you need use SmartyEngin directly
- templating:
-     engines: ['smarty']
  1. There is not kernel.root_dir var. Now we have kernel.project_dir. And default folder is templates
  2. Small change we need in \NoiseLabs\Bundle\SmartyBundle\Extension\SecurityExtension
- return $this->authorizationChecker->isGranted($role, $object);
+ try {
+            return $this->authorizationChecker->isGranted($role, $object);
+       } catch (AuthenticationCredentialsNotFoundException $e) {
+            return false;
+        }
  1. EngineInterface namespace changed;
- use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
+ use Symfony\Component\Templating\EngineInterface;
  1. Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinderInterface removed without replacement
  2. The biggest problem FileLocator interface changed. Now we can't inject anything in FileLocator except $kernel
class FileLocatorFactory
{
    /**
     * @param KernelInterface $kernel A KernelInterface instance
     * @param null|string     $path   The path the global resource directory
     * @param array           $paths  An array of paths where to look for resources
     */
    public static function createFileLocator(KernelInterface $kernel, ?string $path, array $paths, array $extraTemplatePaths): FileLocator
    {
        return new FileLocator($kernel, /**$path, array_merge($paths, $extraTemplatePaths)*/);
    }
}
  1. Small problems with tests. They can be easily solved except this problem with FileLocator

php8 compatibility

I have some "php Deprecated" messages after switching to php 8.
All connected with plugins:

PHP Deprecated:  Required parameter $controller follows optional parameter $parameters in vendor/noiselabs/smarty-bundle/Extension/ActionsExtension.php on line 76
PHP Deprecated:  Required parameter $template follows optional parameter $parameters in vendor/noiselabs/smarty-bundle/Extension/ActionsExtension.php on line 76
PHP Deprecated:  Required parameter $repeat follows optional parameter $parameters in vendor/noiselabs/smarty-bundle/Extension/ActionsExtension.php on line 76
PHP Deprecated:  Required parameter $template follows optional parameter $parameters in vendor/noiselabs/smarty-bundle/Extension/AssetsExtension.php on line 87
PHP Deprecated:  Required parameter $repeat follows optional parameter $parameters in vendor/noiselabs/smarty-bundle/Extension/AssetsExtension.php on line 87
PHP Deprecated:  Required parameter $template follows optional parameter $parameters in vendor/noiselabs/smarty-bundle/Extension/AssetsExtension.php on line 119
PHP Deprecated:  Required parameter $template follows optional parameter $parameters in vendor/noiselabs/smarty-bundle/Extension/RoutingExtension.php on line 85
PHP Deprecated:  Required parameter $repeat follows optional parameter $parameters in vendor/noiselabs/smarty-bundle/Extension/RoutingExtension.php on line 85
PHP Deprecated:  Required parameter $template follows optional parameter $parameters in vendor/noiselabs/smarty-bundle/Extension/RoutingExtension.php on line 98
PHP Deprecated:  Required parameter $repeat follows optional parameter $parameters in vendor/noiselabs/smarty-bundle/Extension/RoutingExtension.php on line 98
PHP Deprecated:  Required parameter $template follows optional parameter $params in vendor/noiselabs/smarty-bundle/Extension/TranslationExtension.php on line 75
PHP Deprecated:  Required parameter $repeat follows optional parameter $params in vendor/noiselabs/smarty-bundle/Extension/TranslationExtension.php on line 75
PHP Deprecated:  Required parameter $template follows optional parameter $params in vendor/noiselabs/smarty-bundle/Extension/TranslationExtension.php on line 109
PHP Deprecated:  Required parameter $repeat follows optional parameter $params in vendor/noiselabs/smarty-bundle/Extension/TranslationExtension.php on line 109

In some cases we don't use all parameters in method.

public function renderBlockAction(array $parameters = array(), $controller, $template, &$repeat)
    {
        // only output on the closing tag
        if (!$repeat) {
            $parameters = array_merge(array(
                'attributes'    => array(),
                'options'       => array()
            ), $parameters);

            return $this->render($controller, $parameters['attributes'], $parameters['options']);
        }
    }

Is there any reason to have $template parameter in this method?
Also, I think set $repeat default value as null will be safe.

renderBlockAction(array $parameters = array(), $controller, &$repeat = null)

And I believe, change parameter order will be a good idea. But it will break BC

Required File Smarty.class.php

Symfony 2.1 uses composer, and the Smarty class can be autoloaded automatically.
The service file smarty.xml, contains an obsolete reference to Smarty.class.php file. This file is no longer necessarily on the include path, and can cause issues.

I guess I would recommend to remove the file requirement for recent version... I solved my issues by commenting out the file reference for now...

noiselabs/smarty-bundle/NoiseLabs/Bundle/SmartyBundle/Resources/config/smarty.xml

%smarty.class_file%

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.