Comments (6)
Hi @eMarek,
no, but you can write route to file:
Be careful, because you lose a features of controller.
from framework.
Hmmm, I will try. I just testing angular.js a little bit.
So what is the difference between self.responseFile(req, res, self.path.public(filename), filename);
and self.file(name + '.html');
as you used it in the issue #22 (comment).
from framework.
https://github.com/petersirka/partial.js/blob/master/index.js#L5190
Why did you add .json file extension to url?
from framework.
Hard to explain. :D
I am learning MVVM frameworks and angular.js is one of them. Let's say this way. I make two ajax calls from browser to server. With first one I am getting view. It is pure HTML file with some ng stuff without any data. With second one I am getting date (JSON). This two things (view and data) are combined by the angular.js in the browser. Why am I doing it like this? Because of so called two way data-binding. You can modify JSON and this will be reflected in the DOM tree and vice versa. The idea is sth like this:
exports.install = function(framework) {
framework.route('/', index);
framework.route('/products.html', productsHTML, ['+xhr']);
framework.route('/products.json', productsJSON, ['+xhr']);
};
function index() {
var self = this;
self.view('app');
}
function productsHTML() {
var self = this;
//returning just view
self.file('../views/products/index.html');
}
function productsJSON() {
var self = this;
//data from DB
self.json({...});
}
The easiest fix for my problem is to replace dots in routes with dashes.
framework.route('/products-html', productsHTML, ['+xhr']);
framework.route('/products-json', productsJSON, ['+xhr']);
Anyway, I will satisfy myself with this ugly notation, if you do not have any better solution. :D
About the controller responding with self.file(...);
... It is very usefull, tnx.
from framework.
Hi, this is my tip:
HTML
- all templates you can store in public directory
- is there auto HTTP cache
- you don't need to write a controller
/public/views/products.html
/public/views/users.html
JSON
- generate in a controller
- more options
from framework.
This solution looks workable but I my case is a little bit to opened. My app will be behind authentication and I do not want to have public views. After all I think I will load views with controller. I have not decided yet.
Anyway, thank you for the help.
from framework.
Related Issues (20)
- How to ignore U.request() causing self signed certificate in certificate chain error. HOT 3
- [feature] : How to create custom node (component) using python script HOT 4
- Serve Angular components views using TotalJS HOT 3
- How can I validate with schema.define the workflow options? HOT 8
- DBMS PostgreSQL doesn't catch an error HOT 1
- How to store information from a test to reuse it HOT 4
- Please help to fix Bug in REST COMPONENT HOT 6
- How to validate the response schema from unit testing method? HOT 5
- What is substitution for CONFIG method in total.js V4? HOT 4
- AUTH global function is recieving undefined in $.params HOT 4
- Trying to get in touch regarding a security issue HOT 2
- F.snapshotstats is not a function at FrameworkCacheProto.recycle HOT 1
- Total v4 is not sending operation object when using EXEC HOT 5
- How to hide X-Powered-By for security reason? HOT 1
- Timeout Set Up HOT 4
- How to onload in totaljs 4 HOT 2
- How to set CORS for public files? HOT 3
- Exporting the JSON HOT 6
- How to load config file and read config as independent library? HOT 4
- How to custom response 408 timeout on spesific route? HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from framework.