mnot / hinclude Goto Github PK
View Code? Open in Web Editor NEWdeclarative client-side inclusion for the Web
Home Page: https://mnot.github.io/hinclude/
License: MIT License
declarative client-side inclusion for the Web
Home Page: https://mnot.github.io/hinclude/
License: MIT License
I have an old project that requires version 0.9.5 but it fails to install because that version lacks a package.json file. The package.json file is the latest commit, but there are currently no new releases.
I'm afraid I'm gonna have to include master, but that's not a very nice thing to do.
Sorry if this has an obvious answer, but could you specify the supported browsers' versions somewhere, please?
can you make a new stable release
Hi,
I think it should be nice to have hinclude send and "X-Requested-With" header with the value "XMLHttpRequest"
Most js framework send this header with ajax requests and the server side framework i know (including symfony2 which has support for hinclude) use this header to help detect ajax requests
Thanks
Tom
Maybe I'm missing something here, but with the current version, there is no way to actually access the refresh feature of hinclude.
Since there is no exports once the file is loaded and ran you can no longer call hinclude.refresh('element-id');
as hinclude is not in the global scope, nor able to be required or imported.
Open to corrections or suggestions?
It should use https://mnot.github.io/hinclude/, not https://mnot.github.com/hinclude/
Is there a way to call the ajax request only on certain condition, like if the user has a cookie ?
By default, the website contains a anonymous header.
If the user has a user_id
cookie, we call the wanted source.
Today I can still make the ajax call but as 90% of my visitors are anonymous, I don't want to make a useless call.
thanks
In case it's not obvious, I haven't been doing much in this project for some time.
If someone is interested in helping maintain it, please say so here - ideally someone who has made contributions in the past, but anyone who is keen and has some experience maintaining JavaScript projects would be welcome.
Otherwise, I'll likely deprecate the project (that's what I was inclined to do first, but it still appears to be in use elsewhere).
Hi,
The URL http://purl.org/NET/hinclude is redirect to a 404:
http://www.mnot.net/js/hinclude/
See you.
Just politely asking for a tag for v0.9.5 :)
See cdnjs/cdnjs#805
Hi all,
i want use hinclude on a event (click on button)
but i cant "prepare" a hx:include, add a src on event and refresh it
if i do :
<hx:include></hx:include>
i obtain a error "url is null"
so i do :
$('#container').html('<hx:include src="/hincludePage"></hx:include>');
hinclude.run();
do u have a better solution ?
thx for your time
It is not possible to nest hinclude's. If the loaded content of a hinclude has another hinclude inside, nothing happens. Just the default text between the tags is shown.
When using hinclude with IE8 and below, I'm getting an "Unknown Runtime Error" on line 54? This happens with any content I try to render in IE.
include[0].innerHTML = include[1].responseText;
Is it just me?
Edit:
Tried it simply with:
<b>Hello!</b>
User on stack overflow reports that 'back' on IE doesn't refresh content. See:
http://stackoverflow.com/questions/388358/hinclude-caching-problem-on-internet-explorer
I want to include rows in a async fashion to speed up page loading and for better caching of the view fragments.
Therefore I use hinclude.js to load the fragment asynchronously. The fragment just contains a table row (e.g.):
tr
td 29 /td
td 60% /td
td Foo, Bla /td
/tr
Problem is that this is not added as html at the position, the browser does interpret it before positioning it. This leads to the result that all tr and td are stripped away.
Any solution to use hinclude to just load some table rows?
Thanks in advance.
source : http://w3javascript.com/question/async-add-table-rows/
req.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
Line 146 in bf85598
Would love to have default support to "refresh" the hincluded section based on an event.
For example:
window
event called: something_clicked
src
attributeThis can be very usefull when working with session specific data, like a cart, etc.
The hinclude tag could be something like
<hx:include src="/remote.html" data-on="window.something_clicked">Loading...</hx:include>
You can make it a "rule" that the "on" attribute must exists of [css-selector].[event-name]
So next data-on
attributes are valid:
data-on="#my-container.refresh"
data-on=".container.my-custom-event"
Hello, I'm using hinclude with Symfony2 and have on my site a login AJAX, just after the authentication is successful I update the contents of blocks loaded by hinclude, this works very well on all major browsers, but in internet explorer does not work.
Anyone ever had this problem or know how to solve?
The website is: https://www.aprovaconcursos.com.br/questoes-de-concurso/questoes
I'm using hinclude to include a CSRF token in a laravel blade page that has been cached with HTTPCache.
When I put the CSRF token inside the body tag, everything works as expected.
<body>
<form>
<hx:include src="/csrf/input">
<input type="hidden" name="_token" value="2viCQ8L7G0aHOsEQwf811kR2wLoozZl3uhEemshv">
</hx:include>
</form>
</body>
But when I put the CSRF token in a meta tag in the head (for AJAX requests), the head gets mixed up when I look in the web inspector. The hx:include tag has been moved to the body(!), and every tag that comes AFTER the hx:include tag in the head, is also moved to the body. See code example below.
My question is: am I doing something wrong here? Or are we not supposed to us the hx:include tag in the head?
View source (Chrome):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="/assets/themes/ambion2020/js/vendor/hinclude/hinclude.js"></script>
<hx:include src="/csrf/meta"></hx:include>
<meta name="description" content="">
<meta name="keywords" content="">
</head>
<body>
<div class="wrapper"></div>
</body>
</html>
Web Inspector (Chrome/Firefox):
<html lang="en"><head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="/assets/themes/ambion2020/js/vendor/hinclude/hinclude.js"></script>
</head>
<body>
<hx:include src="/csrf/meta" class="included include_200">
<meta name="csrf-token" content="2viCQ8L7G0aHOsEQwf811kR2wLoozZl3uhEemshv">
</hx:include>
<meta name="description" content="">
<meta name="keywords" content="">
<div class="wrapper"></div>
</body>
</html>
I've read #13, but I'm unsure, if that arguments fits here, because it is a slightly different suggestions.
To keep things together, whats about data-*
-attributes instead of meta-elements
<script
data-include-mode="async"
data-include-timeout="2"
src="/lib/hinclude.js"
type="text/javascript">
</script>
One argument is, that both are not really documents metadata, but values for the script
I would like to provide my controller object like this with hinclude.js :
{{ render_hinclude(controller("AppBundle:Default:Test"), { 'my_object': object }) }}
Unfortunately I got this error:
An exception has been thrown during the rendering of a template ("Controller attributes cannot contain non-scalar/non-null values (value for key "object" is not a scalar or null).")
Can you help me ?
Thanks in advance !
I would be useful to know when a include has finished loading and is ready for instance to be used in Javascript.
Hi,
is there a way to call the refresh of an ?
Something like $('hx:include').refresh();
HInclude does a good job of fetching HTML and injecting that into the DOM. This obviously requires the data to be rendered server side. I would like to explore the possibility of extending this with the ability to render data client side.
There are quite a few JavaScript libraries for taking JSON data and render it in HTML. One of my favorite ones is mustache.js. It can be extended with ICanHaz.js to allow you to define the templates inline in the HTML.
I would love something like this for HInclude, so it can help remove the glue code you need today if you want to fetch JSON and have it rendered in HTML. The following is an example of what it could look like.
<hx:render src="/api/members.json">
<h1>Meet our <em>{{count}}</em> members!</h1>
<ul>
{{#members}}
<li>{{name}}</li>
{{/members}}
</ul>
</hx:render>
What do you think of this idea? Would functionality along these lines fit within the scope of HInclude?
Hello,
i would like use hinclude for a e-commerce website. The system is friendly with google and others ?
Thanks to you ! 👍
I have a question… search engines are able to see the content of a include?
Hi,
in refresh method you call include method, but missing media parameter :
refresh method :
refresh: function (element_id) {
var i = 0;
var mode = this.get_meta("include_mode", "buffered");
var callback = function (element, req) {};
callback = this.set_content_buffered;
for (i; i < this.includes.length; i += 1) {
if (this.includes[i].getAttribute("id") === element_id) {
this.include(this.includes[i], this.includes[i].getAttribute("src"), callback);
}
}
},
include method :
include: function (element, url, media, incl_cb) { ... }
will be :
refresh: function (element_id) {
var i = 0;
var mode = this.get_meta("include_mode", "buffered");
var callback = function (element, req) {};
callback = this.set_content_buffered;
for (i; i < this.includes.length; i += 1) {
if (this.includes[i].getAttribute("id") === element_id) {
this.include(this.includes[i], this.includes[i].getAttribute("src"), this.includes[i].getAttribute("media"), callback);
}
}
},
Hi @mnot ,
what do you think about switch from this
<hx:include src="http://www.google.it" id="google"></hx>
to this
<div data-src="http://www.google.it" id="google">
?
I dont like so much to add a new namespace, so I would prefer to use a TAG that is already available in DTD.
Can you see any problems in this?
Make sure that addDOMLoadEvent is still relevant / correct, and plays nicely with jquery, etc.
hinclude needs tests; probably Selenium, but maybe also by examining the dom with JS.
I get Unknown Runtime Error on hx:include.innerHTML = something
My tags tree:
<body>
<div>
<aside>
<hx:include ...>
...
I've read already previous issue about ie8, but clean w3c validation don't help me.
I think, may be i achieved this problem because hx:include has display:inline:
http://blog.rakeshpai.me/2007/02/ies-unknown-runtime-error-when-using.html
Sorry for my english.
on a symfony2.6 page I have several blocks that are rendered by twig render_hinclude.
The response content doesn't updated asynchronously but waits while all hinclude requests will finish and then updates all blocks with corresponding content.
Is it possible to make it to display content immediately as request is finished.
thanks
Hi,
I am not really sure whether the problem is on mnot/hinclude repository but when bower downloads https://github.com/mnot/hinclude/archive/v1.0.1.tar.gz
the hinclude.js file seems to be outdated (trigger_event, set_class are missing, ...)
I have tried to clean my cache but nothing has changed.
Thank you for your work.
As hinclude is now used within Symfony2 (it's in their docs), I came across an issue I hope could be fixed.
The issue was reported here.
The gist of the issue is that I'm using hinclude to retrieve data that I want to display multiple times on my page (not really an edge case). If I want this to happen, I can either make multiple requests for the same data (very poor).. or use JavaScript to write a loop that waits for hinclude to perform it's stuff, parses for the data between the <hinclude>
tags, and then propogates this throughout the code.
As a result of using JS to perform this, I feel that I might as well ditch hinclude and use a regular XMLHTTPRequest or jQuery's $.ajax()
.
I really don't want to go down the road of pulling in jQuery if I can avoid it. Please could you suggest whether or not a solution for this could be obtained?
Would it be possible to personalize the method of the XMLHttpRequest for each include with attribute "method" on the hinclude tag with GET by default ?
<hx:include src="/src" method="post"></hx:include>
?
http://mnot.github.io/hinclude/
is not working.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.