I am using Node.js with Express as a server. The user can upload a .CSV file with data. I'm parsing these data and store this in a main array composed of arrays (each line = one array). For now, I'm rendering a page (made with Pug) with this variable.
res.render('index', { rows });
The page is rendering as I would like to the user. However, I'd like to save the rendered "index" in a HTML file. The goal is to convert the HTML file into a PDF (which already works as a result of previous tests with static HTML).
Is it possible to save the rendered page as a HTML file? I'd like to take advantage of the feature of passing variable through the render function.
Another solution would be to generate by myself the HTML file, and do my own logic inside the Node.js route. That seems a long and useless solution since the render function do it well. I just need to save it instead of rendering it.
You could call PUG directly to trigger a render and then save the produced file (https://pugjs.org/)
So basically the issue I am facing is that I have a database with a lot of data in it. So when i query using $http, i get a response. The response is a large amount of data and when I bind it to the model it's very difficult to read the data.
So currently I post data into the database from an android app with html tags and then use ng-bind html to render it as html. This is causing trouble analyzing the data. What can be done to avoid HTML tags and still render the data so it is readable. The attached images will further help you understand.
This is how it looks with html tags and ng bind
This is how it looks without html tags, not very pretty and readabale.
The highlighted portion is how the data arrives. I need to get rid of those tags which are messing up the database. However the entire complaint portion value is associated with one key.
I was also facing the same problem while working on my project. And the easiest solution I get is to use the markdown language.In this, you can store your data in the form of markdowns and when you retrieve them by using markdown parser you will get a better data. there are a lot of markdown parser available. I recommend using "marked.js".
I am using laravel, vuejs.
Its a simple question. But i need to know if it works before creating it. So what i am currently doing is
I have a WYSIWYG editor. I am saving the content from it into a html file and i am storing the location to that html file as a reference in my database
When the user requests a page, I am retrieving that html file and send the content to the page and place the content in the page.
Now to the question, I need to place adsense code between some contents in the html piece(returned from the server). The html is a whole content returned from the php server. Right?
So how can i place adsense code between each paragraph or so after the content is returned from server?
You should really consider storing content in a DB. But if you really need to store HTML in files for some reason, you can use HTML tags like !adsense! in your editor. Then just read HTML from a file and use str_replace or similar function to replace this tag with actual ad code.
As Alexey said, you may consider storing the content on the DB.
Also, you could consider actually using markdown instead of HTML, you could still use the WYSIWYG, but is easier to pre process it and easy to convert to HTML.
That being said, I second that the best option is to either use "key" to be replaced after, but that would mean giving the control to the person who edits if he wants to add the ad or not.
I would actually think you should pre process that HTML, there are some libraries to pre process it or you could use a regular expression, but, bottom line, you read the HTML before you output it, and find out what is a paragraph (depends on how your WYSIWYG is formatting things, this is why I prefer markdown), for example, you could split it in paragraphs based on the P tags or something like that, and then re assemble that, but adding the ad every X paragraphs, that way you can control how and when you put the ad, instead of the person who edits it.
To pre process the HTML you could use something like one of the following options:
Symphony DOM Crawler (recomended): http://symfony.com/doc/current/components/dom_crawler.html
PHP DOM Functions: http://php.net/manual/en/book.dom.php
A PHP HTML Parser Library: https://github.com/paquettg/php-html-parser
Or something similar.
I have tabbed angularjs application, is it possible to get the html page out of my current page which has the model variables.
so for example i have table
<td>book.name<td>
It displays the value but the view source has only this book.name. is there a angular function to get this static html view?
so I will get
<td>.Net<td>
Edit: Trying to convert the html into OpenXML. Use it later to convert to different office documents. leave out certain parts add some parts etc would be easier that way in OpenXML format
In order to keep my page clean i have created a few javascript files that are combined at production mode into fewer files.
I am using a data- attribute in body to determine which script to run.The problem is that when i need some initial data.In this case i use a script tag and put there a json array with my data.
These data may change so i am wondering whether it is better to make a json request for the data and not put them in my page directly ?