ishchenko / idea-nginx

nginx server support plugin for IntelliJ IDEA
Do What The F*ck You Want To Public License
140 stars 39 forks source link

Can you support alternative Jinja2 tags. #54

Open rquadling opened 8 years ago

rquadling commented 8 years ago

Hi.

Several things.

We are moving from single box Apache to multiple nginx cluster, moving from direct ssh to box to Vagrant+Ansible.

As a consequence, our conf files have entries like ...

server {
    listen {{ item.port }};
}

The {{ item.port }} part is a template entry that will be replaced by Ansible.

But, when viewing this in PHPStorm, all sorts of wrong. And reformatting goes out the window!

server {
    listen {
    {
        item.port
    }
};

Upon undo-ing that autoformat, I got an error (https://github.com/ishchenko/idea-nginx/issues/53).

In http://docs.ansible.com/ansible/template_module.html, we are told we can use an alternative tagging mechanism that doesn't conflict with the nginx format.

#jinja2:variable_start_string:'[%' , variable_end_string:'%]', trim_blocks: False
server {
    listen [% item.port %];
}

All is well with that. Nearly.

For

server {
    root [% vhosts_path %]/[% item.domain %]/httpdocs/[% item.document_root %];
}

I'm getting an error saying "Wrong number of parameters for root. Expected 1, got 7.". Which is true if you take the spacing inside the template tags into consideration.

But if you remove the white space (or treat the tag as a single entity), the error goes away and all is well in the world.

Thanks.