1

I'm using Kohana to create an e-mail view which is entirely plain text as a part of a MIME Multipart/alternative e-mail. Since plaintext does not really allow for formatting, I want to be able to use interpolated strings to allow escaped characters so I can create new lines, tabs, etc.

However, using Kohana's built in method for rendering a view:

View::factory('view_file')->render()

always gives me what I believe is a string literal. If I simply create a interpolated string on my own, the escaped characters are created. Using the above method, however, always gives me a literal string so escape codes like \r \t \n appear literally the same in the body of the e-mail.

Is there some way for me to convert the entire string returned by the render() method so that it's an interpolated string in PHP?

The reason I want to do this is because I'm using separate views for the HTML and plaintext versions of the e-mail templates, and I want to stick to this convention while being able to use escaped characters in the plaintext version for minimal formatting purposes.

I have already tried embedding the output of the render method into a interpolated string like $view = "$view", but it's my understanding the string gets created and set as it is being made, regardless of whether it's interpolated or literal.

rene
  • 41,474
  • 78
  • 114
  • 152
atomey
  • 33
  • 6
  • Nevermind, I can just use the literal string to create the formatting and avoid the use of special characters. Duh... – atomey Feb 21 '13 at 19:52
  • I also want to add this: you can still embed interpreted strings (e.g. "string\nhere") into a Kohana view and they will be executed properly. It's very important to distinguish between ' and " when using PHP strings and using special escape codes. – atomey Feb 22 '13 at 21:58
  • Possible duplicate of [How can I interpolate an existing php string literal inside a json file?](https://stackoverflow.com/questions/31107732/how-can-i-interpolate-an-existing-php-string-literal-inside-a-json-file) – Paul Sweatte May 31 '17 at 06:25

0 Answers0