Code Monkey home page Code Monkey logo

liipxsltbundle's Introduction

UNMAINTAINED

This bundle is no longer maintained. Feel free to fork it if needed.

XsltBundle

Renderer for XSLT templates in Symfony2.

Installation

  1. Add the following lines in your deps file:

    [LiipXsltBundle]
        git=http://github.com/liip/LiipXsltBundle.git
        target=/bundles/Liip/XsltBundle
    
  2. Run the vendors script:

    $ php bin/vendors install
    
  3. Add the Liip namespace to your autoloader:

    // app/autoload.php
    $loader->registerNamespaces(array(
        'Liip' => __DIR__.'/../vendor/bundles',
        // your other namespaces
    ));
    
  4. Add the bundle to your application kernel:

    // app/AppKernel.php
    public function registerBundles()
    {
        return array(
            // ...
            new Liip\XsltBundle\LiipXsltBundle(),
            // ...
        );
    }
    
  5. Enable the XSLT template engine in the config

    # app/config/config.yml
    # ...
    templating:      { engines: ['twig', 'xslt'] }
    # ...
    

Usage

Create an XSLT file in your views folder. Then in your controller simply call, where the name of the Bundle is HelloBundle and the name of the controller is HelloController:

return $this->render('HelloBundle:Hello:index.html.xsl', array('name' => $name));

Extensions

Extension can be used to add global data to the XML or to register PHP function callbacks.

This bundle already includes different extensions. To use them, use this in your application config:

# app/config/config.yml
liip_xslt:
     extensions: [liip_xslt.extension.environment, liip_xslt.extension.routes, liip_xslt.extension.debug]

liipxsltbundle's People

Contributors

fabian avatar johnwards avatar lsmith77 avatar seldaek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

liipxsltbundle's Issues

"Traversable" Handling

Currently the handling of arrays only works with arrays not Traversable objects.

I currently haven't come up with a nice solution to get the keys from a Traversable object to test if its fully sequential or not. The only way I can think is to Traverse the entire array to gather the keys for testing.

I'll have a bit of a longer think on it.

Attributes on elements

It was discussed on twitter about adding this to the serializer in core, however I don't think Jordi is keen on that idea. Rightly so in my mind, it is something however that we need in the XSLT view bundle.

Attributes is something that you need a lot in XSLT and deep in the tree as well.

How I have solved this in the past is to have an @ variable name as the key so something like this:

$arr = array(
    "Foo" => array(
        "@id"=> 1,
        "Bar"=>"val"
    ),
);

<page>
    <Foo id="1">
        <Bar>val</Bar>
    </Foo>
</page>

Thoughts? I have the code kicking about, just need to extend the serializer I guess. Need to spend some time with it, but only if it is useful.

Dealing with other variable types

In selectNodeType we currently deal with the following "types" of variables:

Arrays
Objects with toArray
SimpleXMLElement objects
Traversable objects (possibly to be removed)
Numeric values
String values
Boolean values
DomNode objects

If we encounter any other type of variable it doesn't get converted so is lost.

Are their other variables or object methods we should be testing for?

The first one off the top of my head is a "toString" method or the magic "__toString" method. Or maybe the last resort is to cast everything else as a string and hope for the best.....but I've got worries about that idea!

In the 1.x version I had special handlers for form objects which called render on each of the available widgets. Something else to consider?

Other suggestions? Opinions on the above?

Calling routes from XSL

Okay I've hacked together a quick proof of concept.

https://gist.github.com/784301

It's hacky, especially the creating json and parsing it. Also I'm sure you can get access to the instance of the XsltEngine variable but I'm not sure of its name, also as I'm creating the document within the XsltEngine instance that might be a bit difficult.

Other issues, if the router throws an exception you are in trouble. I've tried a "try/catch" with no success but that might be due to me being in dev mode. Again not explored it too much.

I've committed it in my fork, but I'm not sure its ready for a merge just yet as I've only spent 10 minutes on it.

johnwards@4ea467f

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.