Convert hyphens to underscores for jinja variable syntax#7
Convert hyphens to underscores for jinja variable syntax#7Scotchester merged 2 commits intocfpb:masterfrom kurtrwall:attachment
Conversation
|
I think we should probably do this, but I'm curious, what currently happens if there's a hyphenated name in the JSON output? We simply can't access it in Jinja? |
|
That's right. To test, try to replace an image with the |
|
So this change shouldn't break anything already in place, correct? |
|
No because it's only looking for hyphens and replacing those with underscores. The only code that accesses those variables by the hyphened name doesn't access it through the |
|
👍 I just noticed that the README includes a line stating the current stable version. This seems unnecessary, given the version number in the main PHP file and the tags/releases. Can you please remove that README line in this PR? Let's make this and #5 (when that gets updated to use |
|
Just ran into a place where this would be useful. Gonna go ahead and merge so I can update it in my UnityBox WordPress. |
Convert hyphens to underscores for jinja variable syntax
|
This only applies to images? We need this to apply to all custom fields. |
|
Also, any particular reason why |
|
This may be silly, but would using brackets instead of dot notation be helpful here?
|
|
I think that works, but I do love the simplicity of the dot notation... Are you implicitly arguing for not forcibly converting them? I can see the argument for that. "Either don't use them when you define your keys, or deal with bracket notation." |
|
P.S.: I have a working modification to fix the custom field names running locally. |
|
Actually, I didn't know if there was a reason why we couldn't use bracket notation that I hadn't seen yet. I'm a little hesitant about forcibly converting, especially in cases where something like |
|
Could probably use opinions from other FEWDs that have worked with WordPress data in Sheer. /cc @virginiacc @cfarm @jimmynotjim @sebworks @anselmbradford @himedlooff |
|
@KimberlyMunoz makes a good point about the bracket notation, though I share the same sentiment as @Scotchester about the dot notation. To be clear, this PR came out of a choice in Wordpress to use the
|
|
I guess I'm coming around to not doing this. People can either avoid hyphens, or deal with the bracket notation. |
|
Do we want to revert the PR then? |
|
Yeah, I think we do. @KimberlyMunoz, what do you think? |
|
I think so. If we're going to revert, better to do it quick before things get built on it. |
Any data that needs to be accessed in jinja2 is through a named variable that holds that data. The naming syntax of jinja2 does not allow hyphens. This takes any variable named with a hyphen and converts the hyphen into underscores.
@dpford @Scotchester @willbarton