Initial support for Smarty available

Thanks to Martin Fousek, we now have support for Smarty Template Engine. He also wrote this blog post:

Base support of another PHP Framework in NetBeans is on the way. It's presentation framework Smarty which is well-known tool for separating application and visual logic. First versions of the support we just added to the development Update Center so should be available in plugins of every dev build of NetBeans IDE under the name "PHP Smarty Framework".

For now there are these functions for .tpl files:

  • recognizing as a Smarty templates and creating them via New File Wizard
  • syntax highlighting with possibility to change default colors in Tools > Options > Fonts&Colors - SMARTY Templates
  • HTML functionality (HTML navigator, HTML code completion)
  • PHP syntax highlighting for {php}{/php} tags

Functions which aren't supported yet:

  • code completion for Smarty keywords and PHP code
  • using another than standard Smarty delimiters

Syntax highlighting for Smarty templates

Syntax highlighting of embedded PHP in .tpl files

Please report all issues you find in NetBeans IssueZilla > contrib > Smarty, thanks.

Comments:

I have NetBeans code-templates for autocompletion in Smarty-files. If you want them, just drop me a line. Should be copy'&'paste.

Posted by Tom on March 25, 2010 at 06:45 AM CET #

Again, simply awesome. Thanks!

By the way - I wanted all the goodies from 6.9 but was afraid that development builds will be unstable. I'm running 6.9 a week and everything's fine so far :-)

(There are occasional freezes for few seconds though).

Posted by eddie on March 25, 2010 at 06:46 AM CET #

Where is option for defining other as standard delimiters?

Posted by Pet on March 25, 2010 at 08:11 AM CET #

Where is option for defining other as standard delimiters?

I love NB more and more!

Posted by Pet on March 25, 2010 at 08:12 AM CET #

Thanks for this!!!
Where is option for defining other as standard delimiters?

I love NB more and more!

Posted by Pet on March 25, 2010 at 08:13 AM CET #

THANKS!!!

Where is the option for defining custom delimiters?

Love NB more and more

Posted by Pet on March 25, 2010 at 08:23 AM CET #

Great work guys!

Posted by ezod on March 25, 2010 at 08:40 AM CET #

This is the greatest news about Netbeans for a long time :-)

Posted by Franquin on March 25, 2010 at 09:05 AM CET #

Hi, great news!
Do you plan support for \*.phtml files too? Some frameworks with smarty-like syntax use it instead of \*.tpl.

Thanks

Posted by Crempa on March 25, 2010 at 09:28 AM CET #

What file extensions are supported for Smarty templating, only \*.tpl ? I have my templates in \*.phtml file, is it posible to configure smarty support for other file extensions ?

Posted by SmartyMan on March 25, 2010 at 10:37 AM CET #

To Crempa: Not for now, it would be quite difficult so only TPL files are supported now.

Posted by Tomas Mysik on March 25, 2010 at 10:39 AM CET #

To SmartyMan: I already answered in my previous comment.

Posted by Tomas Mysik on March 25, 2010 at 10:40 AM CET #

Hello,

what's about a new stable build? I'm still using 6.9M1, because there is no stable build for a long long time...

Urkman

Posted by Urkman on March 25, 2010 at 12:01 PM CET #

Please add it to the http://plugins.netbeans.org/PluginPortal/

Posted by FDisk on March 25, 2010 at 12:25 PM CET #

To Pet: As was mentioned above, custom delimiters aren't supported yet. It should be supported in next version of the plugin.

Posted by Martin Fousek on March 25, 2010 at 01:01 PM CET #

To Crempa and SmartyMan: The only way how to do that for now is to set .phtml
files as text/x-tpl MIME type in Options -> Miscellaneous -> Files. But
then you can't use .phtml files for PHP code.

Posted by Martin Fousek on March 25, 2010 at 02:07 PM CET #

That is awesome. Thanks!

But you HAVE TO ADD SUPPORT FOR CUSTOM DELIMITERS! Sorry to shout that but that is so important. We like many others don't use the standard smarty delimiters because they don't play nicely with JavaScript. So please, please add that support.

Once again thanks for you work.

Posted by Jeff Whiting on March 25, 2010 at 02:08 PM CET #

To FDisk: For beta or release of NB6.9 should be support of Smarty framework
available on beta Update Center.

Posted by Martin Fousek on March 25, 2010 at 02:11 PM CET #

@Tom

Please, post it on forum or mailing list or somewhere else

Posted by guest on March 25, 2010 at 02:12 PM CET #

I can not find the smarty plugins. I downloaded the latest - NetBeans IDE Dev (Build 201002152000)
Then I checked for updates. Then I chose Tools> Plugins> Available Plugins
and entered into the search box: smarty
Could you give us a link to the installation manual?

Greetings from Lithuania.

Posted by FDisk on March 25, 2010 at 03:14 PM CET #

To FDisk: I'm affraid that you have version from February (2010 02 15). The lastest builds you can find here: http://bits.netbeans.org/download/trunk/nightly/latest/

Posted by Martin Fousek on March 26, 2010 at 01:41 AM CET #

cool, but without custom delimiters not really useful for me...

Posted by NB on March 26, 2010 at 01:51 AM CET #

Thanks. Seem to be working pretty smooth.

Posted by Andreas Burø on March 26, 2010 at 05:22 AM CET #

I suppose that custom delimiters could be there in one or two weeks.

Posted by Martin Fousek on March 26, 2010 at 06:56 AM CET #

@Martin Fousek

Thanks! It's most important option in this plugin. I mean autocompletion and goto's are important as well :)

Posted by Pet on March 26, 2010 at 11:08 AM CET #

Greetings from Brno :)

Thank you for creating this plugin, it will be very usefull for me.

Did I understand well you ate planning option of changing standard delimiters to another one ? I use <{ ... }> instead of standard {...} will it be possible to use your plugin ?

Thank you for your work.
Regards
Winsik

Posted by Winsik on March 31, 2010 at 03:58 AM CEST #

To Winsik: Right. By the way, thanks to Tomas Mysik was implemented needed NB API. So only implementation in Smarty plugin remains.

Posted by Martin Fousek on March 31, 2010 at 03:25 PM CEST #

What about CakePHP support? If I'm not mistaken, it is planned for Netbeans 6.9.

Posted by Sklodowski on March 31, 2010 at 10:01 PM CEST #

To Sklodowski:
Unfortunately, CakePHP won't be supported by NB 6.9.

Posted by Tomas Mysik on April 01, 2010 at 03:01 AM CEST #

Hi,

Why does the standard PHP template not get the same behavior? No highlight or block matching for

<?php foreach (): ?>

<?php endforeach; ?>

or

<?php if (): ?>

<?php endif; ?>

It is really a big mistake because Smarty does get as much attention as in the past. Standard PHP template is much more popular.

nosmarty.net

Posted by pcdinh on April 04, 2010 at 10:39 AM CEST #

@pcdinh What's your point? It already IS highlighted! Even in older versions of NetBeans it works fine.

Maybe you forgot to register the file-extension as PHP-file? You might want to try \*.php instead!

Posted by Tom on April 08, 2010 at 11:58 AM CEST #

@Tom

I attached a screenshot taken for Netbeans 6.8 for your reference.

http://img512.imageshack.us/img512/2913/netbeanshighlighted.png

As you can see, NB 6.8 does not highlight the blocks: <?php if (...): ?> and <?php endif; ?>

The same in Netbeans 6.9 daily builds. (I reinstall my Netbeans 6.9 everyday)

My point is that if you support if/else/endif, foreach/endforeach tag highlighting for Smarty, you should do the same as in pure PHP template because it is much more popular. Smarty does not gain mindset in PHP community recent years because of the increasing MVC adoption.

Although people does not need Smarty any more and they know how to create PHP templates in a smarter and more discipline manner using pure PHP template and MVC, the support of if/else/endif tag highlighting is really expected.

Thanks

Posted by pcdinh on April 08, 2010 at 10:41 PM CEST #

@pcdinh

Well, syntax is recognized, only background is not of different color. IMO, you should file an issue for this, as people did for SMARTY support. SMARTY could be bad or good, but as developer you need support for it. Personally, I'm happy NB support SMARTY

Posted by Pet on April 09, 2010 at 02:31 AM CEST #

I have created new bug for this (http://netbeans.org/bugzilla/show_bug.cgi?id=183988).

Posted by Petr Pisl on April 13, 2010 at 06:00 AM CEST #

I've updated plugin, and now delimiter can be configured. Could we have multiple valid delimiter?

I have to deal with different templates, which using different delimiters.

Thanks!

Posted by Pet on April 13, 2010 at 10:44 AM CEST #

Not able to configure the delimiter. :(
I have installed the Version: 1.20 of PHP Smarty Framework today.

I am not able to see the template for "Smarty Template". The "open in editor" button is disabled for that template.

Posted by Sabyasachi Ruj on April 14, 2010 at 08:13 AM CEST #

Custom delimiters will be published on the blog today. Please, let's discuss everything about them in new entry.

To Sabyasachi Ruj: Maybe it will be because you haven't any SMARTY template within first two dir-levels in your project directory.

Posted by Martin Fousek on April 15, 2010 at 02:08 AM CEST #

@Martin,

Waiting for the blog post.

"To Sabyasachi Ruj: Maybe it will be because you haven't any SMARTY template within first two dir-levels in your project directory."

I have created a sample test project where I have a test.tpl in the same directory where "nbproject" directory is.

This is my directory structure:
--> smarty-test/
----> nbproject/
----> index.php
----> test.tpl

If I am correct, by editing the template only I could configure delimiters. Am I right?

Posted by Sabyasachi Ruj on April 16, 2010 at 03:52 AM CEST #

I've been waiting for this feature!

NetBeans IDE Dev (Build 201004190200), SMARTY plugin 1.20:
I wanted to set my .phtml files to be recognized as SMARTY templates. I followed instructions here (Options -> Miscellaneous -> Files: then set .phtml files as text/x-tpl MIME type), but nothing happened. At the same time it works if I rename .phtml file to .tpl.

One more thing: In .tpl file I can see highlighting as it's shown here, but when click on smarty function start (e.g. {if}) editor doesn't show the end ({/if}. I think it's important when you have complicated nested structure of conditions or foralls. Do you plan support for this?

Posted by Ali on April 19, 2010 at 04:10 AM CEST #

I can't find smarty in plugin update center of netbeans 6.9. Any way to install the plugin on this version ?
Thanks !!

Posted by masev on May 10, 2010 at 11:02 AM CEST #

I downloaded NetBeans Dev 201005290001 and didn't find Smarty plugin there. How I can get Smarty support in this version?
Thanks.

Posted by Slava on May 31, 2010 at 06:17 PM CEST #

Hi,

Could You add support for Twig template language http://www.twig-project.org/ ?

It will be very nice :)

Posted by Piotr on June 08, 2010 at 05:00 AM CEST #

Does anyone know when autocompletion might be available with this plugin in netbeans 6.9?

Posted by Marco on June 24, 2010 at 03:05 AM CEST #

My workaround for the missing codecompletion:

- Use code template for plain text
- File > New File > Other > Empty File
- Save file without the .tpl extension
- now use shortcut + TAB for snippet
- rename file with .tpl suffix

As mentioned - only a workaround.

You can store the template as PHP template, but then you need the openening and closing php-tags which must be removed after inserting the template (since we want a smarty template) plus the rename procedure - so a plain text file is easier.

Posted by Planzelle on August 23, 2010 at 09:48 AM CEST #

Look at http://www.twig-project.org/book/06-Recipes.

// Twig syntax
'tag_comment' => array('{#', '#}'),
'tag_block' => array('{%', '%}'),
'tag_variable' => array('{{', '}}'),

// Ruby erb syntax
'tag_comment' => array('<%#', '%>'),
'tag_block' => array('<%', '%>'),
'tag_variable' => array('<%=', '%>'),

// SGML Comment Syntax
'tag_comment' => array('<!--#', '-->'),
'tag_block' => array('<!--', '-->'),
'tag_variable' => array('${', '}'),

// Smarty like
'tag_comment' => array('{\*', '\*}'),
'tag_block' => array('{', '}'),
'tag_variable' => array('{$', '}'),

Posted by Piotr on September 27, 2010 at 05:18 AM CEST #

At first I couldn't find the PHP Smarty Framework while searching via the 6.9.1 IDE. Turns out the plugin is listed under the NetBeans Beta repository. Is this plugin (version 1.26) still considered a beta?

Posted by Gregg on February 07, 2011 at 12:17 AM CET #

PHP Smarty Framework plugin was placed on Beta UC because it was easier due to quality (for stable UC it has to be tested by QE and there wasn't resources for this). For 7.0 release it should be available on Plugin Portal UC.

@Piotr - Sorry, not planned for now but feel free to enter enhancement http://netbeans.org/bugzilla/enter_bug.cgi?product=contrib&component=Smarty&cf_bug_type=ENHANCEMENT.

@Marco - Lightweight CC is done for 7.0.

Posted by Martin Fousek on March 08, 2011 at 01:37 AM CET #

Post a Comment:
  • HTML Syntax: NOT allowed
About

This blogs is written by NetBeans developers who contribute to the PHP support mainly.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today