I have this error
An exception has been thrown during the rendering of a template
("Named route does not exist for name: auth.signup").
This is the TWIG code for the NAV template
<li>Sign up</li>
This is the ROUTE definition
$app->group('/auth', function () {
$this->get('/signup', 'App\Controllers\Auth\AuthController:getSignup')
->setName('auth.signup');
$this->post('/signup', 'App\Controllers\Auth\AuthController:postSignup');
$this->get('/signin', 'App\Controllers\Auth\AuthController:getSignin')
->setName('auth.signin');
$this->post('/signin', 'App\Controllers\Auth\AuthController:postSignin');
});
I'm stumped because the SIGNIN template code works just fine
<form action="{{ path_for('auth.signup') }}" method="post" autocomplete="off">
Any ideas?
I found the issue. I'm new to this and I thought was being cleaver... to cleaver for my own good. I had my route collections in separate files and would only load the route asked for. Seems that TWIG needs the containers that hold PATH_FOR values as well. I put all the routes in a single file and it works fine
Related
This problem only just appeared when I migrated my code to production, it does not happen in my development environment.
I have a handlebars template which receives an object, something like:
{node: {sections: [{name: 'abc'},{name: 'xyz'}]}}
The template looks like this:
{{#each node.sections}}
{{#ifCond type '==' "image-left-text-right"}}
{{> admin/section/image-left-text-right}}
{{/ifCond}}
{{#ifCond type '==' "two-columns-image-and-text"}}
{{> admin/section/two-columns-image-and-text}}
{{/ifCond}}
{{#ifCond type '==' "four-columns"}}
{{> admin/section/four-columns}}
{{/ifCond}}
{{/each}}
Now this all looks great in my development environment and the template renders correctly, in production nothing shows.
After console logging my entire object I can confirm it's there, wrote a little helper to help me console log it:
<script>
console.log('----1---')
console.log({{{json node}}})
console.log('----2---')
console.log({{{json node.sections}}})
console.log('----3---')
</script>
What is super weird, is that console.log on the node returns:
However the second console log outputs nothing.
It is like it doesn't have access to that attribute on the object?
I'm running version handlebars#4.7.6 in both dev and prod. Is there some weird private/public flag I'm not aware off in Handlebars I need to set, to allow it to access the array directly?
So, apparently I was wrong, I'm running 4.0.12 in dev and 4.7.6 in production. the ^4.0.12 in the package.json file caused it to install the newer version. Apparently the issue is related to 4.7.6, for now I've changed it to 4.0.12 and will eventually investigate what changes in 4.7.6 have caused this problem.
Some background info: i am working with node.js with the express framework and with mongo and passport.js
So basically i was able to login to my app with the FB login and retrieve some info like username, token, id, displayName and photos. Then this data is saved in to my DB (mongo).
I can read all of the data out in my view with the ejs syntax except for the image.
in my view i have the following code for the image:
<%= user.facebook.profilePic %>
this returns the following output:
https://graph.facebook.com/Grace Yip/picture?type=large
but when i surf to this url in the browser i get the following error message
error: {
message: "(#803) Some of the aliases you requested do not exist: Grace Yip",
type: "OAuthException",
code: 803
}
I tried putting the output of my data in an image tag like so:
<%= img_tag( user.facebook.profilePic ) %>
but then i get an error saying: Error: Failed to lookup view "error" in views directory "/Users/Grace/Desktop/QA/views".
When i remove the img_tag code the view works again.
Any idea how i can show the picture ... I am at a loss.
Thanks in advance!
Greetings,
Grace
i'm use
user.facebook.profilepic is bson string path image http from graph facebook api with passport.js u can Try applying for bson str path
<img src="<%= user.facebook.profilepic %>" alt=""> in .ejs file
You need to encode the URI by using the JavaScript in-built function encodeURI because the URI contains a space in it which is making is invalid:
<%= img_tag(encodeURI(user.facebook.profilePic)) %>
I'm working with polymer and I'm testing all in my local environment and all is working as expected, but the problem is when I'll move it into production, where the url shouldn't be the same as in my local. In node.js I can set it via the config.json file and catch it with app.get('config') or something like that, but in polymer I cant get it, and the only chance I have is to create another endpoint with all the config.json config file, but, and here is the best part, I should hardcode this url in polymer!! (so annoying). There is some way or library or component or something that I'm missing ?
Thanks in advance guys! StackOverflow and the users helped my a lot!
UPDATE
The thing is that I'm using custom elements (because I had handlebars too and there is a little problem with the {{}}) so, in the custom elements that I created I have this (for example in the core-ajax call):
<core-ajax id="login" auto="false" method="POST" contentType="application/json" url="/app/middle/login" ....></core-ajax>
as you can see the url is a little bit hardcoded, I want to use something like this (this is what I have on the node.js endpoint application):
router.post(endpoint.login, function (req, res) {
and I want to got something like that over polymer
<core-ajax id="login" auto="false" method="POST" contentType="application/json" url="{{login}}" ... ></core-ajax>
<script>
Polymer('log-form', {
login: endpoint.login,
ready: function () {
....
})
});
</script>
I'ts more clear now? I'm not so strong on english language.
Thanks Guys, for all!
I am new to nodejs. I am basically using express, and I have to create a form to upload photos. So far I have created a file called upload.handlebars where I have written the following code:
<form enctype="multipart/form-data" action="uploads" method="post">
<input type="file", id = "image", name="image", accept="image/*">
<input type='submit' id='tags' value='Upload'>
I have another file called router.js where I have written the post function. One of the lines in the post function is:
fs.readFile(req.files.image.path, function (err, data) {
However, I get an error as follows:
TypeError: Cannot read property 'image' of undefined at Object.handle....
How should I specify the 'name' of the image file in my router.js?
Make sure you have multiparty middleware enabled.
https://github.com/andrewrk/connect-multiparty
Latest express doesn't come with it.
you can use express to solve this problem quickly. to know more read the folowing page express api reference
for now the following code may help you -
app.post('<your path>',express.bodyParser(),function(req,res){
console.log(req.files);//to get all the files uplaoded
});
make sure express version should 3.4
I have been evaluating couchdb for a project and am using couchapp to develop the prototype. So far all I can only say it that it is an awesome tool. I have however run across a problem (which is surely caused by ignorance of the tool) that I cannot seem to get mustache partials to work and the reason for that I believe is that evently can't find the definitions of the partials I am using.
example out of a message queue evently template (evently/queues/_change/mustache.html)
<div class="queue">{{>queue_info}}</div>
...
and I have a queue_info.html with something like
<h2>{{name}}</h2>
where do I place the "queue_info.html" so that evently would find it and insert it properly? If I put it in the same directory as mustache.html it doesn't work.
Best regards,
Vukasin
ok i have figured this out so I am writing to help anyone who might run into the same issue in the future:
if you have data:
{ "queue_info": { "name": "queuename", "owner": "user1" }, "messages": [...] }
and you want to render the "queue_info" part using a partial you will need to create the partial called "queue_info" (it is important that the partial is called the same as the field) and place it in a file "queue_info.html" located in the subdirectory "partials" of the evently directory you are working in).
so we have evently/queues/_change/mustache.html
<div class="queue">
{{>queue_info}}
{{#messages}}
<div class="message">
author: {{author}}
message: {{text}}
</div>
{{/messages}}
</div>
and evently/queues/_change/partials/queue_info.html
Queue: {{name}}
Owner: {{owner}}
when we push this couchapp to the server we get a result which cascades as expected.
Hope this helps someone :-)