Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: Support data type when using concise syntax #23

Open
barchard opened this issue Jan 6, 2017 · 4 comments
Open

Idea: Support data type when using concise syntax #23

barchard opened this issue Jan 6, 2017 · 4 comments

Comments

@barchard
Copy link

barchard commented Jan 6, 2017

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.

@daniele-orlando
Copy link
Member

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

Thank you very much for the feedback.

@barchard
Copy link
Author

barchard commented Jan 7, 2017

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

@umdieecke
Copy link

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

@daniele-orlando
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants