nodefony / nodefony-docker

Docker Image for nodefony
1 stars 0 forks source link

Error Twig.js extend #1

Open ccamensuli opened 7 years ago

ccamensuli commented 7 years ago

Try to debug route framework 404 500 401 /documention

In container with nginx front twig.js render a strange extend file path

ccamensuli commented 7 years ago

NODEFONY : with twig.renderFile

Thu Feb 23 2017 4:01:41 PM ERROR HTTP KERNEL  : { message: 'Unable to find template file /nodefony//vendors/bundles/frameworkBundle/Resources/views/layout.html.twig',
  name: 'TwigException',
  type: 'TwigException' }

TWIG.JS 0.10.3 (webpack) : ligne 6865 Twig.path.relativePath = function(template, file) console.log(arguments)

{ '0': 
   { id: '/nodefony/src/nodefony/bundles/frameworkBundle/Resources/views/404.html.twig',
     method: 'fs',
     base: '/nodefony',
     path: '/nodefony/src/nodefony/bundles/frameworkBundle/Resources/views/404.html.twig',
     url: undefined,
     name: undefined,
     macros: {},
     options: 
      { strict_variables: false,
        autoescape: false,
        allowInlineIncludes: false,
        rethrow: false,
        namespaces: undefined },
     blocks: {},
     importedBlocks: [],
     originalBlockTokens: {},
     child: { blocks: {} },
     extend: '/vendors/nodefony/bundles/frameworkBundle/Resources/views/layout.html.twig',
     tokens: [ [Object], [Object], [Object] ],
     context: 
      { url: 'http://docker.nodefony/l',
        exception: [Object],
        Controller: 'CONTROLER default',
        bundle: null,
        nodefony: [Object],
        getFlashBag: [Function: bound flashTwig],
        render: [Function: bound render],
        controller: [Function: bound controller],
        trans: [Function: bound trans],
        getLocale: [Function: bound getLocale],
        trans_default_domain: [Function: bound ],
        getTransDefaultDomain: [Function: bound getTransDefaultDomain],
        settings: [Object] } },
  '1': '/vendors/nodefony/bundles/frameworkBundle/Resources/views/layout.html.twig' }

Error parsing twig template : /nodefony/src/nodefony/bundles/frameworkBundle/Resources/views/404.html.twig: 

TwigException: Unable to find template file /nodefony//vendors/bundles/frameworkBundle/Resources/views/layout.html.twig

extend : '/vendors/nodefony/bundles/frameworkBundle/Resources/views/layout.html.twig'

base : /nodefony/
base_path : [ '', 'nodefony', '' ]
new path array :
[ '',
  'nodefony',
  '',
  'vendors',
  'bundles',
  'frameworkBundle',
  'Resources',
  'views',
  'layout.html.twig' ]

error : /nodefony//vendors/bundles/frameworkBundle/Resources/views/layout.html.twig

ccamensuli commented 7 years ago

case absolute file path : in file.replace the template.base must be at the start of file path

example: file = "/vendors/nodefony/bundles/frameworkBundle/Resources/views/layout.html.twig"; template.base = "/nodefony" ;

In repo twig : twig.js/src/twig.path.js:73

if (template.base !== undefined && file.match(relative) == null) {
                file = file.replace(template.base, '');
                base = template.base + sep;
}

// This correction may be sufficient ! ?

if (template.base !== undefined && file.match(relative) == null) {
                var myReg = new RegExp("^"+template.base);
                file = file.replace(myReg, '');
                base = template.base + sep;
}