Skip to content

Commit

Permalink
Merge pull request #565 from humanmade/backport-562-to-v17-branch
Browse files Browse the repository at this point in the history
[Backport v17-branch] Ensure Spyc is available
  • Loading branch information
mikelittle authored Mar 7, 2024
2 parents c0954d1 + 66368a3 commit b5ec9ea
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions inc/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,11 @@ function parse_file( string $file, string $root ) : Page {
$meta = [];
preg_match( '#^---(.+)---\n+#Us', $raw, $yaml_matches );
if ( $yaml_matches ) {
// This library seems to have problems with its autoload configuration
// sometimes so we need to ensure it's available.
if ( ! class_exists( 'Spyc' ) ) {
require_once Altis\ROOT_DIR . '/vendor/mustangostang/spyc/Spyc.php';
}
$meta = Spyc::YAMLLoadString( $yaml_matches[1] );
// Strip YAML doc from the header.
$raw = substr( $raw, strlen( $yaml_matches[0] ) );
Expand Down

0 comments on commit b5ec9ea

Please sign in to comment.