GithubHelp home page GithubHelp logo

alwaysblank / blade-generate Goto Github PK

View Code? Open in Web Editor NEW
63.0 3.0 6.0 48 KB

Forces generation of Blade template cache files for Sage9.

Shell 1.53% PHP 98.10% Gherkin 0.38%
wp-cli wordpress sage wordpress-theme blade-template hacktoberfest

blade-generate's Introduction

Hi Folks

I'm a programmer and taco enthusiast, and I help out users of the Roots stack as part of the Roots team (and occasionally contribute code). I like writing code and documentation.

When I'm not doing those things, I enjoy

Things I've Built

Perhaps you'll find some of them useful! Perhaps not. But here they are anyway.

  • brief - Useful for handling collections of data where you need to gracefully handle non-existence of individual items. More useful than an array, less useful (but also lighter) than Laravel Collections.
  • drawer - Drawer was originally created to handle opening and closing website navigation menus. It still does this very well! But you can use it to do other things too. Simple framework-agnostic JS state management library, built around modifying HTML data attributes for easy CSS integration.
  • plumbing - These are several different tiny packages I made to help with small tasks in WordPress that I kept "solving".
    • normalize-links - Makes it a bit easier to use and interact with the arrays returns by ACF's "link" field type.
    • templates - Allows you to set specific directories for custom templates for pages (and custom post types) in WordPress.
    • responsive-images - Wrapper for handling generating responsive images when using WordPress.
    • acf - Slim interface over ACF's get_field() that mostly just adds the ability to get several fields at once--and the ability to provide defaults and run callbacks on those fields individually.

blade-generate's People

Contributors

alwaysblank avatar tobeycodes avatar

Stargazers

 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

Watchers

 avatar  avatar  avatar

blade-generate's Issues

Package doesn't install with `wp package install [email protected]:alwaysblank/blade-generate.git`

The Error

Composer errors out while trying to install blade-generate with the supplied installation command,

# wp package install [email protected]:alwaysblank/blade-generate.git

Error output:

# wp package install [email protected]:alwaysblank/blade-generate.git
Installing package alwaysblank/blade-generate (dev-master)
Updating /home/user/.wp-cli/packages/composer.json to require the package...
Registering [email protected]:alwaysblank/blade-generate.git as a VCS repository...
Using Composer to install the package...
---
Loading composer repositories with package information
Updating dependencies
Reverted composer.json.
WP-CLI ran out of memory. Please see https://bit.ly/wpclimem for further help.

Replicating the Error

This happened to me on my local macOS and Ubuntu environments, and also my remote Debian environment. The solutions listed at https://bit.ly/wpclimem all seem to deal with memory allocation, but none of them worked for me.

I also tried downloading the package and trying the different options the wp package install command offers:

wp package install <name|git|path|zip>

None of those worked.

Solution?

Finally, I tried installing it to WP-CLI "manually", by requiring the package in ~/.wp-cli/packages/composer.json and adding the GitHub repo as a repository:

{
    "require": {
        "alwaysblank/blade-generate": "dev-master"
    },
    "repositories": {
        "wp-cli": {
            "type": "composer",
            "url": "https://wp-cli.org/package-index/"
        },
        "alwaysblank/blade-generate": {
            "type": "vcs",
            "url": "https://github.com/alwaysblank/blade-generate.git"
        },
    },

Composer returned this lint error:

# composer install
Loading composer repositories with package information
Reading composer.json of alwaysblank/blade-generate (refactor-standards)
Skipped branch refactor-standards, "a2dd1ed3ab743fa933ca2dfaadc507fd665d20d2:composer.json" does not contain valid JSON
Parse error on line 10:
...mand.php" ]        ""    },    "requi
---------------------^
Expected one of: 'EOF', '}', ',', ']'

Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
  - Installing symfony/finder (v2.7.0): Downloading (100%)         
  - Installing alwaysblank/blade-generate (dev-master 876d495): Cloning 876d49514c from cache
Writing lock file
Generating autoload files

However, the package installed and seems to work okay, so I'm not sure if that error is related to the installation?

# wp blade compile
Finding files...
Compiling templates  100% [========================================] 0:00 / 0:00
Success: Templates rendered!

Finally, a funny story: I was trying to install this package because I was getting a white screen of death on certain pages after pushing new templates for them up to my staging server. After taking a detour to try all the above and get it working, I realized that the real reason the templates weren't rendering was because I forgot to save my work and had uploaded empty template files to the server. ๐Ÿคฃ

Allow for multiple/flexible template search paths

Currently this tool is hardcoded to use Sage 9's (current) path for blade templates, which is less than ideal (as evidenced by the fact that I've had to update it twice to modify that hardcoded path).

A better solution would be one (or both, or a combination) of the following:

  • Define path in another way: i.e. pass it as an argument to WP-CLI
  • Allow plugin to discover template locations

Override the default "App" namespace

Summary

We're trying to use blade-generate, but we're getting this error
Error: You don't appear to have installed or activated Sage 9!

I then took a quick look in the package and it appears that you're looking for the App\sage namespace\function.

We're using a heavily customized theme where we've overridden the default App namespace,
which is fully supported in the Sage theme.

Even some packages like soberwp have added wordpress filters to allow users/themes to override the default namespace.

Potential Solution / Examples

../vendor/soberwp/controller/controller.php:

 10  function sage()
 11  {
 12      // Determine if project namespace has been changed
 13      sage = apply_filters('sober/controller/sage/namespace', 'App') . '\sage';
 14  
 15      // Return the function if it exists
 16      if (function_exists($sage)) {
 17          return $sage;
 18      }
 19  
 20      // Return false if function does not exist
 21      return false;
 22  }

../vendor/soberwp/controller/src/Loader.php:

 60  protected function setNamespace()
 61  {
 62      $this->namespace =
 63          (has_filter('sober/controller/namespace')
 64          ? apply_filters('sober/controller/namespace', rtrim($this->namespace))
 65          : 'App\Controllers');
 66  }

Is it possible for you to make a similar solution with filters for this package?

I haven't personally worked with WP_CLI before so i don't know if you have full access to WordPress function or not, like apply_filters();

Not including any dev environments such as PHP version etc since this is more of a logical issue.

Fatal error while compiling templates

I'm trying to compile blade templates in Sage theme, but I got an error:

Finding files...
PHP Fatal error:  Uncaught Error: Call to undefined function App\sage() in /home/vagrant/.wp-cli/packages/vendor/alwaysblank/blade-generate/command.php:92
Stack trace:
#0 [internal function]: BladeCommand->compile(Array, Array)
#1 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(89): call_user_func(Array, Array, Array)
#2 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}(Array, Array)
#3 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(425): call_user_func(Object(Closure), Array, Array)
#4 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(365): WP_CLI\Dispatcher\Subcommand->invoke(Array, Array, Array)
#5 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(388): WP_CLI\Runner->run_command(Array, Array)
#6 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1113): WP_CLI\Runner->_run_command_and_exit()
#7 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/Launc in /home/vagrant/.wp-cli/packages/vendor/alwaysblank/blade-generate/command.php on line 92
Fatal error: Uncaught Error: Call to undefined function App\sage() in /home/vagrant/.wp-cli/packages/vendor/alwaysblank/blade-generate/command.php:92
Stack trace:
#0 [internal function]: BladeCommand->compile(Array, Array)
#1 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(89): call_user_func(Array, Array, Array)
#2 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}(Array, Array)
#3 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(425): call_user_func(Object(Closure), Array, Array)
#4 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(365): WP_CLI\Dispatcher\Subcommand->invoke(Array, Array, Array)
#5 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(388): WP_CLI\Runner->run_command(Array, Array)
#6 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1113): WP_CLI\Runner->_run_command_and_exit()
#7 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/Launc in /home/vagrant/.wp-cli/packages/vendor/alwaysblank/blade-generate/command.php on line 92

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.