Skip to content

Commit

Permalink
Move default static folder from views/static-html to views/static
Browse files Browse the repository at this point in the history
  • Loading branch information
Florens Verschelde committed Sep 19, 2016
1 parent 29edc47 commit a897ccf
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 25 deletions.
10 changes: 5 additions & 5 deletions Controller/StaticController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class StaticController extends Controller {
* List Assetic bundles
*/
public function rootAction() {
return $this->render('TwigExpressBundle:static:list.html.twig', [
return $this->render('TwigExpressBundle::list.html.twig', [
'bundles' => StaticManager::getStaticBundles($this->container)
]);
}
Expand Down Expand Up @@ -147,7 +147,7 @@ private function renderDir($rootPath, $localPath) {
$fileList[] = str_replace('.twig', '', $file->getFilename());
}

return $this->render('TwigExpressBundle:static:index.html.twig', [
return $this->render('TwigExpressBundle::index.html.twig', [
'crumbs' => $breadcrumbs,
'dirList' => $dirList,
'fileList' => $fileList
Expand Down Expand Up @@ -179,7 +179,7 @@ private function render404($path, $lookupPaths) {
}
$message .= "\n</p>";

$response = $this->render('TwigExpressBundle:static:notfound.html.twig', [
$response = $this->render('TwigExpressBundle::notfound.html.twig', [
'crumbs' => $breadcrumbs,
'title' => 'File does not exist',
'message' => $message
Expand Down Expand Up @@ -242,7 +242,7 @@ private function showTwigError(Twig_Error $error) {
$data['codeLang'] = StaticManager::getHighlightLanguage($template);
}

return $this->render('TwigExpressBundle:static:twigerror.html.twig', $data);
return $this->render('TwigExpressBundle::twigerror.html.twig', $data);
}

/**
Expand All @@ -264,7 +264,7 @@ private function showTwigSource($systemPath, $localPath) {
'code' => StaticManager::formatCodeBlock($code, true),
'codeLang' => StaticManager::getHighlightLanguage($localPath)
];
return $this->render('TwigExpressBundle:static:twigsource.html.twig', $data);
return $this->render('TwigExpressBundle::twigsource.html.twig', $data);
}

}
6 changes: 3 additions & 3 deletions Core/StaticManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class StaticManager {

// TODO: replace this path with per-bundle, user-defined configuration
const VIEWS_ROOT = 'Resources/views/static-html';
const VIEWS_ROOT = 'Resources/views/static';

/**
* Cleans up a local resource path, removing trailing slashes, double dots, etc.
Expand Down Expand Up @@ -50,7 +50,7 @@ static function getMediaType($ext) {
}

/**
* List Assetic bundles that have a static-html folder
* List Assetic bundles that have a 'static' views folder
* @param ContainerInterface $container
* @return array|string
*/
Expand All @@ -71,7 +71,7 @@ static function getStaticBundles($container) {
}

/**
* Find a valid static-html bundle matching a case-insensitive string,
* Find a bundle with 'static' views, matching a case-insensitive string,
* and return the bundle's name
* @param ContainerInterface $container
* @param string $shortName - partial bundle name to match
Expand Down
19 changes: 8 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# TwigExpressBundle

Browse and render Twig templates in a Symfony project. This bundle is a port of the [TwigExpress](https://github.com/gradientz/twig-express) tool, and is intended for private front-end prototypes.
Browse and render “static” Twig templates in a Symfony project. This bundle is a port of the [TwigExpress](https://github.com/gradientz/twig-express) tool, and is intended for private front-end prototypes. You might like it if you’re a designer or front-end developer working with Symfony.

**Warning:** do not use this bundle or its routes in production (`prod` environment)!

## Features

1. Gives access to a bundle’s `Resources/views/static-html` folder.
1. Gives access to a bundle’s `Resources/views/static` folder.
2. Shows index pages for this folder and subfolders.
3. Renders Twig templates, and reports Twig errors with an extract of the faulty template.

Note that this bundle’s routes will *not* be able to render templates that depend on data provided by existing controllers. It’s intended for “static” prototypes which don’t depend on any data from databases or services.

## Installation

*This part assumes that you have some basic knowledge about [Composer](https://getcomposer.org/) and `composer.json` config.*
Expand All @@ -27,14 +29,9 @@ Add `gradientz/twig-express-bundle` to your dependencies:
}
```






## Getting started

(1) Put your “static” templates in the `Resources/views/static-html` folder of your bundle(s).
(1) Put your “static” templates in the `Resources/views/static` folder of your bundle(s).

(2) Add this to your routes (for example in `routing_dev.yml`):

Expand All @@ -43,7 +40,7 @@ twig_express:
resource: "@TwigExpressBundle/Resources/config/routing.yml"
```

(3) Make sure your bundle(s) with `static-html` views are listed in Assetic's configuration:
(3) Make sure your bundle(s) with `static` views are listed in Assetic's configuration:

```
assetic:
Expand All @@ -55,7 +52,7 @@ assetic:

## Demo pages

This bundle contains its own demo `static-html` templates. To activate the demo, add this import to your config:
This bundle contains its own demo `static` templates. To activate the demo, add this import to your config:

```
imports:
Expand All @@ -64,4 +61,4 @@ imports:

(It’s a simple config file that adds this bundle to `assetic.bundles`, and declares a Twig global variable. Feel free to imitate this pattern to create static bundle-specific config that is easy to plug in.)

Then navigate to `http://hostname/static/` to see a list your bundles which have `static-html` views.
Then navigate to `http://hostname/static/` to see a list your bundles which have `static` views.
2 changes: 1 addition & 1 deletion Resources/config/demo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


# (Optional) Add to Twig global variables, using a namespace to avoid collisions
# (especially if you have more than one static-html bundle)
# (especially if you have more than one bundle with 'static' views).
twig:
globals:
twig_express:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% set metaTitle = 'Static HTML bundles' %}
{% set showCrumbs = 0 %}
{% set title %}
Bundles with <code>static-html</code> views
Bundles with <code>static</code> views
{% endset %}

{% if not bundles %}
Expand Down Expand Up @@ -32,7 +32,7 @@
<footer>
<strong>About:</strong>
Static HTML bundles must be referenced in the <code>assetic.bundles</code>
config, and must have a <code>Resources/views/static-html</code> folder.
config, and must have a <code>Resources/views/static</code> folder.
</footer>

{% endblock %}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</p>
<hr>
<p>
This bundle has its own config file (<code>Resources/config/static-html.yml</code>)
This bundle has its own config file (<code>Resources/config/demo.yml</code>)
for adding itself to the <code>assetic.bundles</code> list.
</p>
<p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'TwigExpressBundle:static-html:1-simple-demo.html.twig' %}
{% extends 'TwigExpressBundle:static:1-simple-demo.html.twig' %}

{% set metaTitle = 'Loading assets with Assetic' %}

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gradientz/twig-express-bundle",
"description": "Browse and render Twig templates in a Symfony project. This bundle is a port of the TwigExpress tool, and is intended for private front-end prototypes, not public-facing pages.",
"description": "Browse and render “static” Twig templates from bundles in a Symfony project. This bundle is a port of the TwigExpress tool, and is intended for private front-end prototypes, not public-facing pages.",
"license": "MIT",
"require": {
"php": ">=5.4.0",
Expand Down

0 comments on commit a897ccf

Please sign in to comment.