I had some trouble with trying to dynamically echo XSL file contents into YAML data fixture. The reason to do this is to be able to save email XSL templates, which needs to be loaded to database as initial data, in separate XSL files where I can easily edit and maintain them. Those files is needed to be dynamically included in YML data fixtures, while loading data to database. The logical solution would be to use <?php echo file_get_contents('filename') ?>, like it is also used in The Symfony Reference Book - The YAML Format chapter. It does work as long you are echo-ing files which contain 1 line. If the file contains more than one row of text (contains line breaks) it breaks YAML file syntax and parser throws an error. After I had located the trouble maker I came up with easy hack solution, which you can find below. If someone has a better solution please let me know!
-------Helper Class------------ class DataFixtureHelper { public static function file_get_contents_for_yml($file) { $string = file_get_contents($file); $string = str_replace("\n", "\n ", $string); return $string . "\n"; } } ----------YAML----------------- <?php require_once(dirname(__FILE__).'/../../lib/helper/ DataFixtureHelper.class.php'); ?> EmailTemplate: some_email_template: EmailTemplateType: some_email_template_type subject: Some subject reply_to_address: some...@someone.com body_main: | <?php echo DataFixtureHelper::file_get_contents_for_yml('./data/ templates/emails/some-template-html.xsl'); ?> body_alternate: | <?php echo DataFixtureHelper::file_get_contents_for_yml('./data/ templates/emails/some-template-alternate.xsl'); ?> ----------XSL------------------ <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/ Transform"> <xsl:output method="html"/> <xsl:template match="/"> <html> <head> <title>Some title</title> </head> <body> <h1>Some email title</h1> <h2>Dear <xsl:value-of select="/root/customer/name"/></h2> <p>Some text</p> <br /> <p>Best Regards,</p> <p>Some Company</p> </body> </html> </xsl:template> </xsl:stylesheet> -- If you want to report a vulnerability issue on symfony, please send it to security at symfony-project.com You received this message because you are subscribed to the Google Groups "symfony users" group. To post to this group, send email to symfony-users@googlegroups.com To unsubscribe from this group, send email to symfony-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/symfony-users?hl=en To unsubscribe from this group, send email to symfony-users+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.