2017 © Pedro Peláez
 

library querypath-format

QueryPath extension that adds extra methods for formatting node values

image

noi/querypath-format

QueryPath extension that adds extra methods for formatting node values

  • Friday, October 25, 2013
  • by noisan
  • Repository
  • 1 Watchers
  • 2 Stars
  • 11 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

QueryPath FormatExtension

FormatExtension is a QueryPath extension that adds the following methods:, (*1)

  1. format($callback [, $args, [, $... ]])
  2. formatAttr($name, $callback [, $args, [, $... ]])

Installation

With Composer, run:, (*2)

$ php composer.phar require noi/querypath-format "*"

Alternatively, you can edit your composer.json manually and add the following:, (*3)

{
    "require": {
        "noi/querypath-format": "*"
    }
}

Usage

format()

\QueryPath\DOMQuery format(callable $callback [, mixed $args [, $... ]])

A quick example:, (*4)

<root>

_apple_
_orange_
</root>'); $qp->find('div') ->format('strtoupper') ->format('trim', '_') ->format(function ($text) { return '*' . $text . '*'; }); $qp->writeXML();

OUTPUT:, (*5)

<?xml version="1.0"?>
<root>
  <div>*APPLE*</div>
  <div>*ORANGE*</div>
</root>

formatAttr()

\QueryPath\DOMQuery formatAttr(string $name, callable $callback [, mixed $args [, $... ]])

A quick example:, (*6)

<root>' .
        '<item label="_apple_" total="12,345,678" />' .
        '<item label="_orange_" total="987,654,321" />' .
        '</root>');

$qp->find('item')
        ->formatAttr('label', 'trim', '_')
        ->formatAttr('total', 'str_replace[2]', ',', '');

$qp->find('item')->formatAttr('label', function ($value) {
    return ucfirst(strtolower($value));
});

$qp->writeXML();

OUTPUT:, (*7)

<?xml version="1.0"?>
<root>
  <item label="Apple" total="12345678"/>
  <item label="Orange" total="987654321"/>
</root>

License

FormatExtension is licensed under the MIT License - see the LICENSE file for details., (*8)

The Versions

25/10 2013

dev-master

9999999-dev

QueryPath extension that adds extra methods for formatting node values

  Sources   Download

MIT

The Requires

 

by Akihiro Yamanoi

extension xml jquery html format xhtml querypath

25/10 2013

v1.0

1.0.0.0

QueryPath extension that adds extra methods for formatting node values

  Sources   Download

MIT

The Requires

 

by Akihiro Yamanoi

extension xml jquery html format xhtml querypath