开发者

Indentation when using File Template to create new PHP Class in Netbeans

I'm probably missing something, but I have the following issue:

I'm using Netbeans IDE 7.0.

I've created a template for new PHP Classes, but when I try to create a new class, the template I've created is inserted without any indentation.

Example:

Template:

<?php
/**
 * Description of ${name}
 *
 * @author ${user}
 */
include_once("class_functions.php");

class ${name} {
    //Class properties

    function __construct() {
        //Constructor
    }

    public function __get($name) {
        if(method_exists($this, 'get' . ucfirst($name))) {
            return $this->{'get' . ucfirst($name)};
        } else {
            if (property_exists($this, $name)) {
     开发者_开发技巧           $this->{$name} = $value;
            } else {
                throw new Exception("Undefined property '$name'.");
            }
        }
    }
}

But when I use this template, the new class is created like:

<?php
/**
 * Description of ${name}
 *
 * @author ${user}
 */
include_once("class_functions.php");

class ${name} {
//Class properties

function __construct() {
//Constructor
}

public function __get($name) {
if(method_exists($this, 'get' . ucfirst($name))) {
return $this->{'get' . ucfirst($name)};
} else {
if (property_exists($this, $name)) {
$this->{$name} = $value;
} else {
throw new Exception("Undefined property '$name'.");
}
}
}
}

Does anyone know what I'm doing wrong?

Any help is greatly appreciated! Thanks in advance.


Seems if you save your template using tabs it will strip them. Save your templating with spaces used for indenting they will be filtered into tabs or left as spaces per your netbeans preferences.

You may also have syntax issues that will sometimes through the render off.

Also as I said before, alt + shit + f is your friend in netbeans (auto format)


Workaround:

Create your OWN template file and add it to Netbeans File Templates. All the indentations magically starts working...

File templates dialog -> Add

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜