I am working in a project with sails and ejs, I am trying know in which page I am, I mean if I am in the home site, login, register, .... from the template.
When I try to use, is_current_page I got always the error "is not defined" I already try to add express-helpers as I have read in this iss How to configure Sails.js to use EJS view helpers but without successful.
Any Idea ?
I was not able to get Express-Helpers to work with the beta version of Sails either (v10-rc5 at this time). I solved this problem by looking at the path, but I won't claim this is the 'right' solution.
if(res.locals.view.path.split('/')[0] === 'view_name'){ ... }
If there is another way to determine the current view I would be interested as well.
Related
Does anyone have any pointers on how to go about adding a /docs page for website documentation to a next.js app? I've looked up Docusaurus but it seems like it's already a react app itself. Is there a way to integrate it inside an existing next.js app or are there other solutions?
Many Thanks
One idea might be to intercept the request and send the html file that docusaurus builds out, and putting all other files in the public folder.
https://medium.com/wesionary-team/render-html-file-in-pages-of-next-js-59281c46c05
Also checkout this discussion about it.
https://github.com/vercel/next.js/discussions/12373
I have done this with React apps using express. But never with Next. At first it looks like it would be possible with multi-zone in Next but that doesn't seem to do the job. So my other recommendation would be to try to use a docs.domain.com instead and host it separately. Then you have a /docs url or a button that redirects to the doc domain instead.
Firebase has free hosting and allows you to setup multiple sites. So it should be fast to test this setup there
I'm going to actively try to get this to work with Next myself but I do not think it will work because of how they are developed. So I would do the above recommendation and if I find a workaround, I'll post an update.
I have a content type and C# Razor template for a simple page hero built using 2SXC. I also have a DNNSharp MyTokens with a simple token that looks like this: [DBQ:EligibleForExam]
Using the regular DNN HTML module, I can put my token in the source and it renders the value of the token.
I want to display the value of this DNNSharp MyToken inside of the C# Razor template but it doesn't show the value. Furthermore, I want to perform an if else statement on this value.
Here's what I want to do:
#if [DBQ:EligibleForExam] = 1 {
<p>You are eligible for the exam</p>
}
How can I use DNNSharp MyTokens in 2SXC?
In this case you can choose between going all the way 2sxc or all the way DNNSharp :
- scenario 2sxc: translate the DNNSharp token to 2SXC. I don't know what's behind that code but I guess it is some kind of SQL select and/or filters. In 2SXC you can create content types with SQL as a source. In the query designer, you can filter these results.
- scenario DDNSharp: in MyTokens you create a razorscript or HTML and make a token out of that. I don't think you hit any barriers soon following this path.
The core problem is that tokens are not well architected in DNN, there is no officialy "global" token system which knows about the DNN Sharp tokens.
I believe it should be easy to do though: I'm pretty sure there will be some documentation on DNN Sharp how to use their tokens in any c# or MVC page. Probably just 2-3 lines of code. So best check their docs.
2SXC does not render DNNSharp tokens like html module or EasyDNNSolutions do.
It would be an awesome thing as MyTokens and 2SXC are both very powerfull.
But maybe we can fix your problem within 2SXC itself or within DNN Sharp/HTML
What are you trying to accomplish? You can share the case / code here. Or if you feel this is beyond the Q&A setup that Stackoverflow is, you can send me an email.
Cheers
Tycho
I am currently working on a project using Django and Angular. I am trying to implement Django's Password-Reset app, which seems pretty easy to set up. I followed the instructions and I ran into a peculiar issue that is caused by Angular's routing. I am trying to link to a FormView using
Forgot password?
But it seems that Angular's routing keeps picking up the literal translation of the link
http://127.0.0.1:8000/%7B%%20url%20'password_reset_recover'%20%%7D
This of course causes a routing error to pop up.
Is there anyway I can link to this view without Angular interfering?
Looks like the problem is that Django is not parsing your URL tag in the template. Might want to look into that rather than into Angular
Could you check the a tag in your Developer tools and see what it says? Chances are that it says exactly what the URL is pointing to.i.e. /%7B%%20url%20'password_reset_recover'%20%%7D
Have you added password_reset_recover in your root urls.py?
Until the end of my Angular application development period, I worked with two seperate projects. WebApi and Angular SPA.
Now I am trying to deploy them to our production server and because of the need for seperate SSL certificates, we decided to combine them and run in the same Project. So far so good...
I managed to combine them together and the server side code compiles. Now when I run the app, the first call to the API results in a parse error with the homepage contents (full of html). I understand that this is due to the $urlRouterProvider 's otherwise attribute, routing all the non-routed paths to the root "/".
I need to fix it, excluding the paths which includes /api in them in order to bypass Angular's routing system out of API's way. Any ideas to help?
EDIT: New project is a combination of WebApi (v2 - Asp.Net) and Client App (Angular v1.3.15 on MVC5 views. And yes, html5Mode(true) but doesn't change a thing if turned off).
EDIT2: Forgot to mention, the error is raised from a jQuery ajax call, outside the angular scope. :$
As interesting it is, I realized some other abnormalities in the way WebApi worked. Did some research and found out that it's because of the latest EntityFramework (v6.1.3). During my merge, I updated EF from v6.1.1 so uninstalled and 6.1.3 and installed back 6.1.1 and the problem is solved! That is very odd. EF 6.1.3 should have been a solid release without any breaking changes. Very odd...
Thanks to all who commented and tried to help.
EDIT: After some time, what I realized is this. EF models should be in sync with the Database in order to make successful database calls from WebApi. When I make an ajax call and the db is not in sync with the models, the problems in the question occures. I hope that information helps someone.
Is there some way to run UI-Router without running bower/npm, etc?
https://github.com/angular-ui/ui-router
I tried linking to it (just like to angular), but that didn't work. Tried saving it locally in a .js file and referencing it. That didn't work either. Am I missing something or am I just trying to do something impossible?
edit: Alternatively, is there anywhere to test this? Like plunkr or something?
Here's the source for what I think is the latest. I think you should just be able to link to it in a <script /> tag in your index.html:
http://angular-ui.github.io/ui-router/release/angular-ui-router.js
Or copy that to a text file and run it completely locally, since I think you're just trying to test it out. If it didn't work, maybe make sure you have all of its dependencies, if any.
Of course it looks like it's a package in plunkr, so you should be able to try it there. I added it and the latest angular for you (haven't tested it though):
http://plnkr.co/edit/jdX6pRn6noHh1JoP5CH6?p=catalogue
You can write Angular UI routing code into your Notepad++ editor, But you require a normal web server to run it properly.
You can try the Google Chrome Plugin to execute all AngularJS related codes.
Kindly Run all the applications using a local server. There is no need for Tomcat server. You can easily download a Google Chrome Plugin "Web server for Chrome". here- Web Server for Google Chrome
Also the Angular UI routing Snippet is available at: https://github.com/TheAjinkya/AngularSnippets/tree/master/Angular%20UI-Router