Development

#2514 (sfYaml::dump() should have acces to the Spyc-Options $indent and $wordwrap)

You must first sign up to be able to contribute.

Ticket #2514 (closed enhancement: fixed)

Opened 1 year ago

Last modified 10 months ago

sfYaml::dump() should have acces to the Spyc-Options $indent and $wordwrap

Reported by: GatheredPain Assigned to: fabien
Priority: minor Milestone: 1.0.12
Component: other Version: 1.0.8
Keywords: Yaml, sfYaml, dump Cc:
Qualification: Unreviewed

Description

For a CMS i have a little Script that writes the routing.yml by reading out a pages Table of the CMS. The Problem: if the final URL is longer than 40 characters, the sfYaml::dump() method creates an entry with ">" in the beginning, because sfYaml thinks it could be a long Text... Thats OK. But using Syck and reading this routing.yml every URL wich was writen with such a ">" gets an Space-Character in the end. So the genurl() - method generates something like "http://my.domain.com/morethan40characters/index .html". Of course this URL can not be found. After searching a some houres i found a simple solution. I overwrote the dump() Method form sfYaml-Class (sfYaml.class.php). I added the parameters $indent and $wordwrap which are defined in Spyc::dump(). [public static function dump($array, $indent = false, $wordwrap = false) ] and gave them also to the dump()-Method of the class "Spyc" [ return $spyc->dump($array, $indent, $wordwrap); ]

Now I can use the sfYaml::dump() as follows and everything is fine :-)

sfYaml::dump($myArray,false,0) With $wordwrap=0 no String is wraped and my Script is running perfectly also with Syck.

Would be nice to see this Change in the next Update.

Thx for reading...

Change History

11/08/07 13:53:11 changed by GatheredPain

  • type changed from defect to enhancement.

11/09/07 20:54:33 changed by dwhittle

This might not work since we offer two options spyc and syck and the options are not identical. If the only options you want to override are indent and wordwrap, we should be able to add those..

I have faced this issue to.. In reality this is a flaw in the parser not following the yaml spec. I also think we should change the default s to indent and have worwrap at 120 chars, but thats just me..

03/14/08 21:33:09 changed by fabien

  • milestone set to 1.0.12.

03/14/08 21:42:38 changed by fabien

  • status changed from new to closed.
  • resolution set to fixed.

in r7888

03/14/08 22:59:38 changed by fabien

(In [7892]) replaced Spyc with a new YAML parser/dumper (closes #3083, #2887, #2622, #2514, #1966, #1339, #3016)

  • removed Spyc
  • added sfYamlParser, sfYamlDumper (should be totally BC thanks to the unit tests)
  • the parser and the dumper are much more robust and much more easier to fix
  • exceptions are thrown when a non valid YAML file is parsed (when you forget a : after a key for example, or if the indentation is not right ;))
  • fixed a bunch of bugs of the old parser
  • speed is more or less the same as Spyc
  • added an option to control the dump to switch from the block to the flow notation (propel:build-schema is now much more readable in YAML)
  • added more unit tests