2017 © Pedro Peláez
 

symfony-bundle twig-extensions-bundle

Provides helpful Twig extensions for Symfony2

image

ornj/twig-extensions-bundle

Provides helpful Twig extensions for Symfony2

  • Tuesday, August 6, 2013
  • by ornj
  • Repository
  • 1 Watchers
  • 0 Stars
  • 357 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

twig-extensions-bundle

This bundle contains helpful Twig extensions for the Symfony2 framework. These extensions provide simple, front end functionality that is often times present on web pages., (*1)

Installation

Install this bundle in your Symfony2 project by adding it to your composer.json., (*2)

{
    "require": {
        "ornj/twig-extensions-bundle": "dev-master"
    }
}

After running updating composer, register the bundle in app/AppKernel.php., (*3)

 $bundles = array(
    // ...
    new Ornj\Bundle\TwigExtensionsBundle\OrnjTwigExtensionsBundle(),
 );

Included Extensions

is_external

Determines if the url points to a host external to the current site., (*4)

Arguments

  1. host: Provide the host you want to check against. You can get the current host by passing app.request.httpHost.
{{ 'http://www.example.com' | is_external(app.request.httpHost) }}

facebook_share

Generates a url for sharing the current page on Facebook. Accepts the following parameters:, (*5)

Arguments
  1. picture: path to an image
  2. name: the post title
  3. caption: caption to show next to the image
  4. description: content of the post
  5. redirect: where to send the user after they share the post
{{ url('route', { id: entity.id }) | facebook_share('http://example.com/images/img.jpg', 'name', 'caption', 'description', 'example.com/redirect) }}

In addition to the above parameters you must also provide a Facebook application id. Currently the parameter facebook_app_id is being used. You can set the parameter however you'd like. One location this could be defined is in app/config/parameters.yml., (*6)

pinterest_share

Generates a url for sharing the current page on Pinterest. Accepts the following parameters:, (*7)

Arguments
  1. media: path to the media being pinned
  2. description: content of the post
{{ url('route', { id: entity.id }) | pinterest_share('http://example.com/images/img.jpg', 'description') }}

twitter_share

Generates a url for sharing the current page on Twitter. Accepts a message to input into the tweet., (*8)

Arguments
  1. message: Body of the tweet
{{ url('route', { id: entity.id }) | twitter_share('Check out this page!') }}

To Do

  1. Make Facebook app id paramater a config setting instead of a parameter in parameters.yml

The Versions

06/08 2013

dev-master

9999999-dev http://github.com/ornj/twig-bundle

Provides helpful Twig extensions for Symfony2

  Sources   Download

MIT

The Requires

 

twig extension