fluidxml icon indicating copy to clipboard operation
fluidxml copied to clipboard

Idea: Support data type when using concise syntax

Open barchard opened this issue 7 years ago • 4 comments

It would be nice if I could specify the data type when using the concise syntax. For example:

$book->add([ 'title'  => 'The Theory Of Everything',
             'author' => 'S. Hawking',
             'chapters' => [
                    [ 'chapter' => [
                            '@id' => '1',
                            '@:cdata'   => 'Ideas About The Universe' ] ],
                    [ 'chapter' => [
                            '@id' => '2',
                            '@:cdata'   => 'The Expanding Universe' ] ],
           ]]);

Presently, I am forced to call ->add('chapter', true) then ->cdata('Ideas About The Universe') on the node returned from the add call. Obviously, this results in code that isn't very concise :\

Data types based on the current API could be:

  • text
  • cdata
  • comment

Just an idea.

barchard avatar Jan 06 '17 02:01 barchard

Yes, it is good point. I think your proposal will be part of the next release.

Thank you very much for the feedback.

daniele-orlando avatar Jan 07 '17 15:01 daniele-orlando

Awesome, thanks! For backwards compatibility, maybe @ can be analogous to @:text?

barchard avatar Jan 07 '17 15:01 barchard

Is there any update on this? I'd highly appreciate that kind of syntax.

umdieecke avatar Jan 23 '19 16:01 umdieecke

As soon as I'll find time in the next weeks I'll add this feature. Pull Requests are welcome of course.

daniele-orlando avatar Jan 23 '19 16:01 daniele-orlando