I am using RoR with the ember-rails gem on the server side and Ember.js on the client side.
The on the server side located (Handlebars-)templates are delivered in the Ember.TEMPLATES variable on the client side.
These templates can be used within an Ember.View.
All of this works like a charm, but now the problem:
I have a very small piece of html i want to render.
It is, from my point of view, not worth to create a Ember.View for that.
So what i would like to do something like that..
Ember.TEMPLATES.name_of_the_template(
{
my_text_variable : "my_text"
}
);
This raises an error: TypeError: Cannot read property 'buffer' of undefined
I've looked up the code and i know why this happens (the templates can only be used within a Ember.View or maybe other Ember-Objects).
With Handlebars it is working, but there i have no access to the on the server side stored Handlebars-Templates..
Someone has any suggestions how i can solve this?
Please let me know if you need more information!
Thx!
Related
I have implemented a Json-ld dynamic creation process to boost my SEO. The JSON is created through the use of Jbuilder ( code is in a partial), rendered in a script tag with a type of "application/ld+json". All of it is wrapped up in a content_for, so that I can reuse the logic.
Once it has been implemented, I started to get this error in my console: "[Facebook Pixel] - Unable to parse JSON-LD tag. Malformed JSON found: ' "
I tested my Json-LD on the google structured data tool and everything came back ok.
I've added an hand written JSON-LD in my script tag, instead of my aforementioned logic,
everything looked ok. No error was displayed in the console, and Chrome Facebook Pixel
Helper was able to find my JSON-LD.
Bottom line, it appears that using my dynamic logic with the partials create a random " ' ", which makes no sense for me.
Any of you ever had the same issue, or something similar ?
May be templating engine is messing you up. You might consider using the json-ld gem to validate the output as part of continuous integration (you can also semantically validate the content using other gems).
I’ve had success using JSON-LD in Haml, but I just use to_json from a Hash hierarchy which has always worked well for me.
I am making an JSF 2 application. Sometimes I want to do simple things that are easy to do using plain HTML but I get error messages that I don't understand.
For example I sometimes want to write:
Test
But this makes the page break because of "?test1=ee&test2=oo". Having only one parameter seems to be fine but if I try to add more parameters using "&" it complains and says I need to use a ';'-delimiter.
Any explanations why this happens and maybe how to get around it?
I have a url like this: /hello/world#/lol/backbone
I'd like to get access, in ruby, to the full, entire path. I'd normally do something like this: request.fullpath but that returns only /hello/world and leaves off the #/lol/backbone/
Been Googling for awhile. Can't seem to find it.
You can't get the fragment in your server code, the URL fragment (#/lol/backbone) is a client-side issue. The browser will interpret the fragment but it will not send it to your server.
If you need the fragment then you'll have to convert it to a parameter by intercepting your link with a bit of JavaScript, then the server could see something like
/hello/world?frag=/lol/backbone
and you could pull the fragment out of params[:frag]. This does of course assume that your JavaScript link interceptor will get run, that's not guaranteed so your server-side code should be prepared for a missing params[:frag].
I do have a question concerning the development of a gem for Rails 3.
I would like to insert specific HTML snippets/partials/fragments (e.g. a form or an image on a fixed position) into every HTTP get response. I am wondering what technique would be the most appropriate for this use case. I see two solutions, but I am not sure which one will be the better approach.
Rack middleware loaded by a Rails engine: I could write a rack middleware that parses the response HTML document and insert my HTML snippets/partials before the closing body tag. This approach seems to be a little bit dirty, since the proper formatting of the response document is not guaranteed.
Inserting the snippet at the controller level: Maybe as an after_filter?! The problem here is that I somehow have to guarantee that my after_filter will be the last one in the filter chain.
I am curious whether there are further approaches and which one you would pick. It would be great to have access to the standard Rails view helpers from within the partial/snippet I am planning to insert into the response. By loading the gem the snippet should be automatically included into every response without requiring the user to insert a partial at the views.
Thanks in advance
Peter
I'm considering using the hash method to create static urls to content that is managed by ajax calls in a Asp.Net MVC. The proof of concept i'm working on is a profile page /user/profile where one can browse and edit different sections. You could always ask for the following url /user/profile#password to access directly to you profile page, in the change password section
However, i'm wondering if i'm not starting this the bad way, since apparently i can't access the part after the hash in any way, except by declaring a route value for the hash in global.asax. So i'm wondering if this is the right way to access this part of the url?
Am i supposed to declare a route value, or is there another way to work with hash values (a framework, javascript or mvc)?
Edited to add:
In pure javascript, i have no problem using the window.location.hash property, i'm not sure though how standard it is in today's browsers, hence the question about a javascript framework/plugin that would use it.
The thing is that the part that follows the hash (#) is never sent to the server into the HTTP request so the server has absolutely no way of reading it. So no need to waste time in searching for something that doesn't exist.
You could on the other hand tune your routes to generate links that contain the hash part so that client scripts can read it.
Send the hash value document.location.hash as a parameter to the controller action of your choice.
This can be done in the code if needed...
RedirectResult(Url.Action("profile") + "#password");
should work fine