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

Inline version of KirbyText #1442

Merged
merged 3 commits into from
Mar 11, 2019
Merged

Inline version of KirbyText #1442

merged 3 commits into from
Mar 11, 2019

Conversation

distantnative
Copy link
Member

Describe the PR
Adds option for KirbyText to output unwrapped (without wrapping <p> tag) string.
kirbytext($text, false)
->kirbytext(false)

Related issues

Todos

  • Add unit tests for feature
  • Pass all unit tests
  • Fix code style issues with CS fixer and composer fix
  • Documented on getkirby.com

Copy link
Member

@lukasbestle lukasbestle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The additional param is a breaking change as the $data param now moves to third position. I think we should either create a separate method and helper for this behavior or make the params "magic" (so that the order of the additional params doesn't matter).

Also I think we could use Parsedown's line() method instead of stripping the paragraph tags manually. This should be supported down to the markdown component.

@bastianallgeier
Copy link
Member

I agree with @lukasbestle.

@distantnative
Copy link
Member Author

Understood and agreed - can't say yet when I will get to rewrite it though.

@distantnative
Copy link
Member Author

@lukasbestle I am wondering whether it is worth the effort to make the parameters "magic". Or if it would be sufficient to move the new parameter to the last position to not create a breaking change. What do you think?

@lukasbestle
Copy link
Member

You are right about that. It's probably even harmful as it gets a lot more complex.

I think we should avoid methods with a lot of params in general. We had that in v2 in some places (e.g. the Cookie class) and it was sooo hard to find out which param did what, especially if all of them are boolean. The TCPDF library has the same issue and it drives me crazy every time I have to use it.

So what about a completely separate method for this?

@texnixe
Copy link
Member

texnixe commented Mar 5, 2019

So what about a completely separate method for this?

Yes, call it ktRaw(), like we called it in our plugins for Kirby 2. Nice and short.

@distantnative
Copy link
Member Author

Ok 👍 separate method it is. And then I will try to solve it at the markdown component level

@lukasbestle
Copy link
Member

I'm not sure about the ktRaw name. "Raw" would imply that nothing else is done except parsing KirbyText. But actually Markdown is parsed as usual, just without wrapping tags.

Maybe ktInline()? Slightly longer, but I think it makes it clear what happens. Maybe we can find a way to still use the full kirbytext name for it to avoid having abbreviations all over the code. But kirbytextInline is too long. 🤔

@distantnative
Copy link
Member Author

Hmm yea, I feel like adding anything, even just 1-2 characters to kirbytext could make it too long. Something in the direction of kirbytextline? kirbyphrase?

@texnixe
Copy link
Member

texnixe commented Mar 5, 2019

I hardly ever use kirbytext() but prefer the short kt(). I will wrap anything that makes kirbytext() even longer into a nice short custom method 😉

@lukasbestle
Copy link
Member

I don't think we should introduce an entirely new term for this, that could be quite confusing.
Why not both actually? kirbytextInline() with a short alias ktInline().

@texnixe Do we already have a short kt() helper and/or method? I can't find one in the core.

@distantnative
Copy link
Member Author

@nilshoerrmann
Copy link
Contributor

If you have a long kirbytextinline(), why don‘t you call the shortcut kti()?

@lukasbestle
Copy link
Member

👍 for kti!
I think we should also have helpers with the short versions.

@distantnative distantnative changed the title Add raw/unwrapped option for KirbyText Inline version of KirbyText Mar 6, 2019
@distantnative
Copy link
Member Author

@lukasbestle ping - new version. I still don't like the name to be honest 🙈

@distantnative
Copy link
Member Author

Needs a bit of adaption if this PR gets merged: #1543

Copy link
Member

@lukasbestle lukasbestle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should also have inline variants of the markdown helper and field method. Not sure about that though.

Otherwise LGTM. 👍

* @param array $data
* @return string
*/
function kirbytextinline(string $text = null, array $data = []): string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use camelCase for this: kirbytextInline. Same for all other occurrences.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's wait to hear from @bastianallgeier if all else would be ok, before making that change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept it like the rest. Otherwise we would need to change kirbyText, kirbyTags, etc. as well.

@bastianallgeier bastianallgeier merged commit ab40afe into develop Mar 11, 2019
@bastianallgeier bastianallgeier deleted the feature/kirbytext-raw branch March 11, 2019 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement ✨ Suggests an enhancement; improves Kirby
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants