ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Stripping whitespace - tabs, carriage returns, everything, from an embedded template

January 18, 2013 11:31am

Subscribe [2]
  • #1 / Jan 18, 2013 11:31am

    LynneL

    239 posts

    I have an embedded template (called from another template passing it variables) which does some calculations based on a channel that holds the parameters of the calculations in it. So it’s a complex template with lots of code, including loops of Matrix fields, among other things.

    The template is set to PHP on Output as little bits of PHP are doing the actual calculations inside of the loops. (I’m actually quite pleased with myself and my elegant solution for a “modular” set of calculations that the end users of the site can set themselves).

    What I need to be spit out has to have just a number, no whitespace of any kind, no carriage returns, no tabs. The reason if it’s important is that the parent template is actually going to be in CSV format for exporting.

    Now, I have lots of tabbing and carriage returns in my embedded template, or I will never make heads or tails of any debugging I ever have to do. So I could manually get rid of every single return and tab in the template but that route makes me SHUDDER. I will if I have to but am hoping for another solution.

    I’ve tried half a dozen things suggested here and elsewhere…phpstringfun plugin…Hacksaw…etc…nothing is really working. I’m not sure if any of the ones that have complex caching systems are any use…this is going to output very unique calculations pretty often, over and over again, in rows on rows of a CSV.

    Help? Please don’t make me resort to minifying the damn thing manually…granted, I could save a “working copy” with all my tabs and returns, then do a search-replace-all for the different items in my text editor, but what a pain for debug.

  • #2 / Jan 18, 2013 11:38am

    LynneL

    239 posts

    Ugh, and when it comes to that, just my quick test of getting rid of all the \t \r and \n I get a “Parse error: syntax error, unexpected T_VARIABLE in /home/myserverpathwashere/expressionengine/libraries/Functions.php(656) : eval()‘d code on line 1”

    Edit: I can get rid of JUST the \t (tabs), and JUST the \n and \r but not both returns AND tabs, or I get that error. Ugh.

  • #3 / Jan 18, 2013 3:55pm

    MadWebDesigns

    147 posts

    Hi LynneL,

    What version of EE are you using?

    Can you post your parent template code with the child template embedded so we can have a look please?

    Cheers,

    Mike

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases