LemonStand Forum: Non standard use of templates issue - LemonStand Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Non standard use of templates issue

#1 User is offline   mitchkramez 

  • Member
  • PipPipPip
  • Group: Members
  • Posts: 84
  • Joined: 26-February 10

Posted 07 September 2010 - 09:12 AM

In my templates, I've started using:
<? include('resources/templates/home.php'); ?>


to use files for the templates and partials. I realize this is non-standard and non-supported, but this may apply to other cases down the road in a different way:

What i'm running into is that when i include the files that way, LS appears to be putting some extra spaces which add a new empty line at the bottom of my page... you can see the code here:

http://cl.ly/31d2657cc706526a6fcc

if i remove the include line from the template i'm using and just paste in the html from home.php this doesn't happen.

Again, I realize this is not a supported use of the template system, but it seemed odd to me that when i'm including the file with the same code that i'd normally paste in, i get extra whitespace...

Thanks!
0

#2 User is offline   Eric 

  • Developer
  • PipPipPip
  • Group: Members
  • Posts: 1,290
  • Joined: 04-August 10
  • LocationVancouver, Canada

Posted 07 September 2010 - 02:17 PM

I believe the reason for this would be when you use partials the standard way, it captures output, and perhaps any newlines (\r\n) are lost in the process of evaluation. Do you have any lines before or after the HTML or PHP in home.php? If not, I'm not sure..

I don't believe LS overloads include, but try include_once or require_once. You could try strip, var_dump, str_replace, ob_start/end to debug the issue.

If it's just HTML you could use file_get_contents or fopen as instead.

This post has been edited by frosty: 07 September 2010 - 02:18 PM

0

#3 User is offline   Aleksey 

  • Co-Founder
  • Group: +Administrators
  • Posts: 3,633
  • Joined: 31-October 09

Posted 07 September 2010 - 03:30 PM

Hi, Mitch!

I just made a similar test page and didn't notice any extra line breaks. The include() function outputs the file contents just in the place where it is called. Are you sure there are no empty lines after the include() call and in the included files?

#4 User is offline   mitchkramez 

  • Member
  • PipPipPip
  • Group: Members
  • Posts: 84
  • Joined: 26-February 10

Posted 07 September 2010 - 06:11 PM

debuggin in firefox revealed that
an zero width space is being inserted at the end of my document before the closing body tag... i certainly don't have that in there (i'd never even heard of it), and it only appears to happen when i'm doing an include of my template file, when i just have the code inline... does this shed any light on it for anyone else?
0

#5 User is offline   Aleksey 

  • Co-Founder
  • Group: +Administrators
  • Posts: 3,633
  • Joined: 31-October 09

Posted 07 September 2010 - 07:24 PM

Hi, Mitch!

I don't know this symbol as well :-) Please try wrapping the include() call into some tag, for example into a DIV:

<div><? include(...) ?></div>


Will the empty line be inserted before the closing DIV tag?

Thanks

Share this topic:


Page 1 of 1

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users