-
Notifications
You must be signed in to change notification settings - Fork 103
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
Add parameter so text can be optionally not escaped for tag!
#44
base: master
Are you sure you want to change the base?
Conversation
I don't particularly like the bare true/false as the first argument. It's not immediately clear what xml.node(true, "XX") means. I think I would like xml.node("XX", indent: false) better, but I haven't checked to see if that syntax interferes with anything else. Thoughts? |
+1 for this PR. Context: I'd like to merge in a PR that's dependent on these changes: savonrb/gyoku#35 (comment) @jimweirich, instead of a boolean, how about the symbol? I suggest My personal choice (and I believe the most idiomatic) would be to pass optional values like this in a hash eg: |
oops, sorry I somehow missed/forgot about this PR. Anyway my implementation is such because there I couldn't think of any other way how to make this possible. Only way to implement it differently would be with dropping some feature as current way is very flexible for creating tag, but not how to specify options. Also that I'll explain why currently it's not possible to make it different.
Actually there are few ways. One way would be using Symbol indeed (but it can't be first arg as it's used for xml namespace) so |
I think this is a bit of a "whacky" discussion. I think the main "problem" is the decision to stick with a single method xml and try to fit all configuration on the method alone. Gyoky.config do |config|
config.xml ...
config.node ...
config.print ...
end
# or
Gyoky.xml(...).print(...).config(...) Much simpler and easier to extend, understand etc. |
It's Adding global option for escaping isn't that useful, because almost always you want to escape markup and only few times you need to directly add raw markup. Thus you need that option per tag, not global. And method chaining isn't really related to this issue at all, it's that current |
👍 for @kristianmandrup's suggestions. Adding a symbol to the args passed to |
If I want to add node such as
apples & oranges
without double escaping it, I've to do it with block. such asbut output isn't nice...
_indent
is private and so it wouldn't be easy to add indentation myself.With this PR, I added option to
tag!
that you can specify whether to escape text or not. So we can simplywe get nice result
with current implementation, or with
xml.node(true, 'apples & oranges')
orxml.node('apples & oranges')
it would be double escaped