noiselabs / smartybundle Goto Github PK
View Code? Open in Web Editor NEWSmarty3 template engine bundle for Symfony
Home Page: http://smartybundle.readthedocs.io/
License: GNU Lesser General Public License v3.0
Smarty3 template engine bundle for Symfony
Home Page: http://smartybundle.readthedocs.io/
License: GNU Lesser General Public License v3.0
Create a SmartyBundle reference page similar to http://symfony.com/doc/2.1/reference/twig_reference.html
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
what i should do?
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
See GHSA-5pv8-ppvj-4h68 for details
One missing feature I ran into fairly fast was the missing stylesheets and javascripts tag
http://symfony.com/doc/2.0/cookbook/assetic/asset_management.html
Also with support for the yui compressor;
assetic:
filters:
yui_js:
jar: "%kernel.root_dir%/Resources/java/yuicompressor.jar"
I'm sure I'm missing something, but how can I load the smarty template from the database?
Integration with MopaBootstrapBundle (Twitter Bootstrap).
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.
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.
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!
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
I got error if my app have not symfony/form component
I've installed SmartyBundle using composer. Everything went fine.
But now on composer update I've got:
"templating" has a dependency on a non-existent service "templating.engine.smarty"
It looks like there is not a modifier created for csrf_token
Any chance to integrate Smarty stuff into the Web Debug Toolbar?
http://www.symfony-project.org/book/1_0/16-Application-Management-Tools#chapter_16_sub_web_debug_toolbar
@noisebleed could you please tag the master with 1.3.1 to include the csrf_token modifier in the stable version?
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 ?
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?
I opened a issue at smarty, but i also apply's to the SmartyBundle project.
Please take a look at: http://code.google.com/p/smarty-php/issues/detail?id=79
Greetings
Winus
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.
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
Hi,
do you have any idea when you will continue with building for the form and assetic extension ?
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.
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.
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.
In current stable version there is a restriction for smarty version "smarty/smarty": "3.1.*,<=3.1.27"
Would it be fixed soon ?
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 !
Will be support symfony 4?
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 ?
@vitorbrandao Hi! Do you have plans to add sf5 support?
I faced some problems trying to adopt it for sf5.
- templating:
- engines: ['smarty']
kernel.root_dir
var. Now we have kernel.project_dir
. And default folder is templates- return $this->authorizationChecker->isGranted($role, $object);
+ try {
+ return $this->authorizationChecker->isGranted($role, $object);
+ } catch (AuthenticationCredentialsNotFoundException $e) {
+ return false;
+ }
- use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
+ use Symfony\Component\Templating\EngineInterface;
Symfony\Bundle\FrameworkBundle\CacheWarmer\TemplateFinderInterface
removed without replacementclass 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)*/);
}
}
I am asking because I saw that the last commits have been 3 years ago. But did you abandon this project?
Do you plan Symfony 3.1 support? Any ETA?
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
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%A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.