HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Multiple TextFormatters, Vanilla One wins

SS ✭✭
edited July 2010 in Feedback
@Mark
There is problem: Impossible format text with more than one method.
In Vanilla 1 we can do that by adding Formatter to StringManipulator class.

Vanilla 2 (what we can do):
Gdn_Format::Format() is static, not pluggable (PHP < 5.3).
1. Edit views solution
$Text = Gdn_Format::Html($Text);
$Text = Gdn_Format::To($Text, 'MyMethod');
...
Unacceptable.
Tagged:

Comments

  • ToddTodd Vanilla Staff
    edited July 2010
    If you want to plug into the formatter using 'MyMethod' in your example above you would do the following:
    1. Make a class with a method called Format($Text).
    2. Install the class with the following line of code:

    Gdn::FactoryInstall('MyMethodFormatter', 'MyMethodClass', 'PathToClass', Gdn::FactorySingleton);
    Check out the HtmLawed plugin to see how this is done. And if you want to have all new comments/discussions formatted with your formatter you can add the following to your config:

    $Configuration['Garden']['InputFormatter'] = 'MyMethod';
  • SS ✭✭
    edited July 2010
    Thanks @Todd. I'll check it.
    The fact is that I still use RC1 with HtmlPurifier.

    And I'm not sure that I correct explain what I need.
    For example, default format method for comments is "Html".
    I created plugin which can do the same what doing Format::Html() with minor changes.
    And someone created another plugin Format::Html() + minor changes.

    Will these 2 (3, 5, 10, ...) plugins correct works together for "Html" format method?
  • TimTim Vanilla Staff
    @Todd I think @S wants format chaining

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • SS ✭✭
    @Tim Exactly. Mention doesn't work for me :(
  • SS ✭✭
    Ah, work, but nick not linked.
Sign In or Register to comment.