How can I get Rails ApplicationController.render to render a template in variable instead of sending it back to browser? Basically what I am trying to do is to prepare an email content in my controller by making a template in views file with locals and then rendering the template by passing locals in variable which will be set as content of email.
Related
By default, nuxt adds a route for each page in pages.
I want to make when going to the page e.g. project.local/id/ec29cjsa5fas512ik, the user goes to a page template and the Vue receives this ec29cjsa5fas512ik id from the url so it can make proper API calls later.
You can make a dynamic page in Nuxt2 with the following file, eg.
/pages/details/_id.vue
then you'll have a path like /details/:id.
More info can be found here: https://nuxtjs.org/docs/features/file-system-routing#dynamic-routes
I was hoping someone had any insight on this basic approach. Sample scenario:
I have a dashboard template with menu links a(href "/page") and I want to click the links to render a different section/view on the template. I used block content...but does it need a specific route?
If I understand correctly, you want to update the content of the page on click of the link without the page getting refreshed.
In that case, no you can't do it using block content.
The purpose of block content is to apply inheritance in your templates.
The typical use of block content would be creating a layout and then creating more specific page from the layout. This is what the official documentation says.
The reason why you cannot do it because, jade is server side templating library. This resolves the block content on server. Once rendered in client, the html looses all the information that was specific to jade (which is obvious because its an html afterall).
What you can do here is
Create a /page.jade and make a ajax call to a service. That service should return an already compiled html string. Since you are using jade, you can easily use jade.compile(source, options) to template / generate html.
Jade API documentation here
I´m using AspPDF together with Classic ASP to create PDF files and I have a page that is build dinamically based on POST requests.
After that, I need to get this HTML that has been dinamically created and insert all of it inside a variable, so then I can send it to AspPDF method at the end of the page.
(I know AspPDF has a method that converts page based on URL, it does not work for me in my specific case)
Because I have several if statements and loops, I have no idea how to store all current HTML generated in a variable.
Any ideas on that?
Thanks
i am not familiar with AspPDF, but my question is:
can you store everything in some variable and once html completly generated then send content by using
Response.Write VarHTML
Because I have several if statements and loops, I have no idea how to store all current HTML generated in a variable.
like this:
VarHTML = VarHTML & "your html code"
VarHTML -- just variable you create
I'm working on my first chrome extension, and using an image-based context menu item to capture the URL of a given image, and want to then display that image at a specific URL in a new tab. So, I need to pass the URL of the image clicked on (using srcUrl) to a specific script that can then render it on that page. Is it possible to perform an HMLHttpRequest from within a chrome.tabs.create() call, or must this be done some other way?
Thanks for any help.
You would need to create an HTML page containing that script and put it into your extension folder. Then you can just pass image url to it as GET parameter:
chrome.tabs.create({url: "local.html?img_url=...");
If url parameter is not enough, you would be also able to communicate with that page using chrome.tabs.sendRequest():
chrome.tabs.create({url: "local.html", function(tab){
chrome.tabs.sendRequest(tab.id, {img_url: "local.html?img_url=...");
));
With the request listener in that page:
chrome.extension.onRequest.addListener(function(request) {
console.log(request.img_url);
});
In my Rails app, I want to update the contents of a header element in my application wide layout and have that content depend on which controller is handling the request. For example, if UserController is handling the request, then the header element content could be "User Page", but if the PhotoController is handling the request then the header element content could be "Photo Page". The solutions I've came up with (using content_for or setting instance variables) all seem to require code duplication and I'm looking for a DRY implementation. Is there a Rails variable that I can use in my view that reflects the current controller?
You can use the params[:controller] variable to determine this, or if you want something longer then controller.controller_name.