Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2005-11-10 05:59:59
- boblet
- Member
- Registered: 2005-08-08
- Posts: 53
No line breaks for conditionals that aren't true
Hi All,
I use txp:if_
tags (too?) heavily, and it seems as though every conditional tag will add a newline to the HTML code, even if it doesn’t evaluate as true. This gives me pages with large blank gaps (in the HTML, not on the displayed page) where 7 conditionals were false and one was true. This is definitely a very minor thing, but since I was thinking about it (and since the alternative is stripping newlines outta my forms, making them a lot less readable) I thought I’d write it down.
peace – boblet
Offline
Re: No line breaks for conditionals that aren't true
Can you post some example code? It sounds like it could be your own linebreaks between (i.e.outside of) the conditionals. For example if you have:
<txp:if_a>
blah
</txp:if_a>
<txp:if_b>
blah
</txp:if_b>
my page
There is a line-break after </txp:if_a>
and </txp:if_b>
that is outside of the conditional, and tht’s nothing that should be affected by the conditional.
Offline
#3 2005-11-10 08:45:16
- boblet
- Member
- Registered: 2005-08-08
- Posts: 53
Re: No line breaks for conditionals that aren't true
Hey Sencer,
thanks for your reply. Here’s the kind of conditional madness I’m living with to support a fully bilingual site with clean urls
My body id form (dev_body_id
):
<code><txp:if_section name=“about,about.en,about.ja”><body id=“page-about”></txp:if_section>
<txp:if_section name=“portfolio,portfolio.en,portfolio.ja”><body id=“page-portfolio”></txp:if_section>
<txp:if_section name=“log,log.en,log.ja”><body id=“page-log”></txp:if_section>
<txp:if_section name=“contact,contact.en,contact.ja”><body id=“page-contact”></txp:if_section></code>
Called from this page template:
<code></head>
<!— template:archive —>
<txp:output_form form=“dev-body-id” /> <div id=“page”>
</code>
Gives the following HTML code (numbers added to stop blank lines being killed, since pre
doesn’t work):
<code>1<!— template:archive —>
2<body id=“page-about”>
3
4
5
6
7
8 <div id=“page”></code>
For the last section the body tag is 3 lines lower down:
<code>1</head>
2<!— template:archive —>
3
4
5
6<body id=“page-contact”>
7
8 <div id=“page”></code>
So it seems I’ll get the newlines between each txp:if_section
call I do in the HTML. I don’t know if this is normally a good thing, and it definitely won’t affect output, but it does make my HTML code look a little sloppy ;-)
Interestingly having a newline after the opening txp:if_section
and before the closing tag doesn’t change the output:
<code><txp:if_section name=“about,about.en,about.ja”> <body id=“page-about”>
</txp:if_section>
<txp:if_section name=“portfolio,portfolio.en,portfolio.ja”> <body id=“page-portfolio”>
</txp:if_section>
<txp:if_section name=“log,log.en,log.ja”> <body id=“page-log”>
</txp:if_section>
<txp:if_section name=“contact,contact.en,contact.ja”> <body id=“page-contact”>
</txp:if_section></code>
this gives the same HTML code as the first option.
Removing all newlines gives the result I expected (although it in turn looks pretty ugly. hah!) – form:
<code><txp:if_section name=“about,about.en,about.ja”><body id=“page-about”></txp:if_section><txp:if_section name=“portfolio,portfolio.en,portfolio.ja”><body id=“page-portfolio”></txp:if_section><txp:if_section name=“log,log.en,log.ja”><body id=“page-log”></txp:if_section><txp:if_section name=“contact,contact.en,contact.ja”><body id=“page-contact”></txp:if_section></code>
html:
<code><!— template:archive —>
<body id=“page-contact”> <div id=“page”>
</code>
Honestly Sencer, this is really unimportant (compared to, say, my other problems ;-) Thanks for taking the time though!
peace – boblet
PS what’s up with that dang pre
tag? this forum really doesn’t like it huh
Last edited by boblet (2005-11-10 08:58:37)
Offline