Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Controling whitespace in jinja2 macro
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Jānis Ģeņģeris  
View profile  
 More options Oct 23 2012, 5:18 am
From: Jānis Ģeņģeris <janis.genge...@gmail.com>
Date: Tue, 23 Oct 2012 02:18:03 -0700 (PDT)
Local: Tues, Oct 23 2012 5:18 am
Subject: Controling whitespace in jinja2 macro

Hello.

How to control whitespace inside a macro?

I have the following jinja2 macro http://pastebin.com/CDsT2wMw, and when
net_gw or net_bcast is not present I got an empty
line, like here :
http://pastebin.com/q3SsTxs8

, but I would like to have the empty line removed from the final
replacement and have the output as here:
http://pastebin.com/vhDfT4mA

Is it possible to do that?

Regards,
--janis


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon Sapin  
View profile  
 More options Oct 23 2012, 5:28 am
From: Simon Sapin <simon.sa...@exyr.org>
Date: Tue, 23 Oct 2012 11:28:12 +0200
Local: Tues, Oct 23 2012 5:28 am
Subject: Re: Controling whitespace in jinja2 macro
Le 23/10/2012 11:18, Jānis Ģeņģeris a écrit :

> Hello.

> How to control whitespace inside a macro?

Hi,

See http://jinja.pocoo.org/docs/templates/#whitespace-control

--
Simon Sapin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jānis Ģeņģeris  
View profile  
 More options Oct 23 2012, 6:30 am
From: Jānis Ģeņģeris <janis.genge...@gmail.com>
Date: Tue, 23 Oct 2012 03:30:50 -0700 (PDT)
Local: Tues, Oct 23 2012 6:30 am
Subject: Re: Controling whitespace in jinja2 macro

Yes, I have red that, but have no clue how to fix my problem. If I add
minus signs inside the variable braces, then everything goes on single
line, which is not good at all.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Simon Sapin  
View profile  
 More options Oct 23 2012, 7:02 am
From: Simon Sapin <simon.sa...@exyr.org>
Date: Tue, 23 Oct 2012 13:02:35 +0200
Local: Tues, Oct 23 2012 7:02 am
Subject: Re: Controling whitespace in jinja2 macro
Le 23/10/2012 12:30, Jānis Ģeņģeris a écrit :

> Yes, I have red that, but have no clue how to fix my problem. If I add
> minus signs inside the variable braces, then everything goes on single
> line, which is not good at all.

Remember that without the "minus" trick, any whitespace is kept. In this
case, it’s not the whitespace inside the macro definition but around the
call.

Try adding a minus on both calls:

   {{- net_param(...

And removing this one in the macro:

   if value %}

--
Simon Sapin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jānis Ģeņģeris  
View profile  
 More options Oct 23 2012, 7:57 am
From: Jānis Ģeņģeris <janis.genge...@gmail.com>
Date: Tue, 23 Oct 2012 04:57:44 -0700 (PDT)
Local: Tues, Oct 23 2012 7:57 am
Subject: Re: Controling whitespace in jinja2 macro

Your suggestion gives this output: http://pastebin.com/9ixeagYG

I think, I'll give up on this, takes too much time ;>. Thanks.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
deBrice  
View profile  
 More options Nov 5 2012, 4:57 pm
From: deBrice <bbrriic...@gmail.com>
Date: Mon, 5 Nov 2012 13:57:29 -0800 (PST)
Local: Mon, Nov 5 2012 4:57 pm
Subject: Re: Controling whitespace in jinja2 macro

{{ net_param('gateway', net_gw) }}{{ "\n" -}}


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »