<?php

namespace Kachkaev\JstmplBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

class JstmplController extends Controller
{
    public function indexAction($name)
    {
        foreach ($this->container->getParameter('jstmpl.source.patterns') as $v) {
            try {
                $response = $this->render(str_replace('{name}',$name, $v));
                return $response;
            } catch (\InvalidArgumentException $e) {
            }
        }

        throw new NotFoundHttpException();
    }
}