What is the syntax to use React fragments in Reason-React - reason

There is this old chat that suggests writing your own fragment wrapper, but I understand that fragment should now be natively supported.
However I couldn't quickly find the correct syntax for it.
Example of what I'm looking for:
<fragment>
<button label="foo"/>
<button label="bar"/>
</fragment>

Here is the official documentation page on reason-react and fragments.
The syntax for using React fragments in reason-react is this:
<>
<button label="foo"/>
<button label="bar"/>
</>
The terse syntax may be easy to miss if you are looking hard for something like <Fragment> (this is what happened to me). I first found the answer in the release notes for version 0.5.0

Related

Handlebars formatting in NetBeans

I'm using NetBeans as my IDE for a Ember.js project. When I create handlebars templates in my app like below the code highlighting doesn't work correctly.
<script type="text/x-handlebars">
<div>
</div>
</script>
Normally, when I'd select the first div, it and its matching end tag would highlight yellow, but this doesn't work. Since its inside the handlebars script tag both are highlighted red as errors and don't match together. This makes writing complex templates kinda annoying as it can be difficult to pinpoint syntax errors.
Is there anyway to get NetBeans to highlight inside the handlebars tag as if its regular html?
One option, until Netbeans implements this enhancement, is to add the following script tag in index.html immediately after your reference to jQuery:
<script src="js/libs/jquery.js"></script>
<!-- use following line to change script type to 'text/x-handlebars' -->
<script>jQuery('script[type="text/html"]').attr('type', 'text/x-handlebars');</script>
This is a variation of the answer provided by GCoda.
I had the same problem and tried various non satisfying fixes.
In the end I figured the best solution is simply to change the script's type attribute to text/html:
<script type="text/html">
<div>
</div>
</script>
I got same problem. And i just used a some kind of postprocessing, i am using node.js, so i did res.send(data.replace(/type="text\/html"/g,'type="text/x-handlebars"')); on my / page.
I think you can do something similar in you language, and ofcource this is not a fix, just an ugly trick to make developing more easy. Dont keep it in production.

Integrate Htmls into GWT

We have a web application that its UI is based on GWT.
We are pretty satisfied from the technology, but we have one major problem: We get html files from our designer, and it takes a lot of time to integrate them into our GWT code.
Is there a quick way or rules to do that?
For instance, I would like to take the html, put it almost "as is" in a ui.xml file, and then start binding the components to UiBinder fields.
What is the quickest way to do that? What should I do with the CSS and JS files that I get?
I need some guidelines to make this conversion, so it will be quick & easy.
We have the same problem. It might be hard for a designer to get used to GWT widgets. But he'll have to forget about making HTML proof-of-concepts and using GWT directly.
We didn't overcame the difficulty. As a result, many GWT features are under-used (like CSSResources, or GWT-Bootstrap layout capabilities).
I would advise to have him learn the xml of GWT widget libraries.
You can also start by using GWT Designer. This way he can still do the design, learn the XML bit by bit, and you can still work on wiring the components.
Of course it is a slow process. People don't change old habits instantly.
Errai seems to fit your requirements.
Basically is uses regular HTML5 templates, binded to GWT logic.
"Create standard conform HTML5 templates or use existing HTML and CSS files to design your web and mobile applications."
http://errai.github.io/
Here is an example of a sign-in page:
<!DOCTYPE html>
<link rel=stylesheet href="css/TodoList.css">
<div data-field="main">
<h1>Get it done with Errai.</h1>
<div class=form>
<p class=error data-field=loginError>
Login failed. Please check that your email address and password were entered correctly.
</p>
<input type=text data-field=username placeholder="Email">
<input type=password data-field=password placeholder="Password">
<button data-field=loginButton>Sign In</button>
<p>New here? Sign up in seconds!</p>
</div>
</div>
source
(p.s. I've never used it, yet)

Incorrect MIME type for GET requests

I've been using the Lift Web Framework as a REST only service for quite a while, but I need to use it as a stand alone tool now.
<lift:surround with="default" at="content">
<head>
<script data-lift="with-resource-id" src="/test.js" type="text/javascript"></script>
</head>
<h2>Welcome to your project!</h2>
<p><lift:helloWorld.howdy /></p>
</lift:surround>
I have the above very basic Lift template. The problem is when I view it in the browser something is adding an <?xml> DOCTYPE and the browser defaults to interpreting the resource as XML instead of plain HTML.
How do I tell Jetty/Lift that my static file is HTML?
Sounds like you may be using the XHTML doctype. In your Boot.scala file, you may want to try adding:
LiftRules.htmlProperties.default.set((r: Req) =>
new Html5Properties(r.userAgent))
That should set your application to use HTML5, and should turn off adding the <?xml... encoding header.
Also, as #VasyaNovikov mentioned, the lift: prefixed tags are an older construct (even though a lot of documentation still mentions them). They still work but will have some issues with HTML5. It is recommended to use either of the equivalent forms:
Original:
<lift:surround with="default" at="content">...</lift:surround>
HTML5:
<span data-lift="surround?with=default;at=content"></span>
<span class="lift:surround?with=default;at=content"></span>
If you want to use the lift: variety, the biggest issue you'll find is that in HTML5 the tags and attributes are converted to lowercase, so <lift:helloWorld.howdy /> will be interpreted as <lift:helloworld.howdy />, and Lift will not find the snippet. Using <span data-lift="helloWorld.howdy"></span> should allow you to work around that.
Maybe adding the header will help?
<html>
<head>...
Example:
https://github.com/lift/lift_25_sbt/blob/master/scala_29/lift_basic/src/main/webapp/index.html
In general, you use a very old approach to templates, with custom tags <lift:surround>, <lift:helloWorld> and such. Where did you get them? I suggest to use the new template style like in the link I posted.

dynamic feedback with JSF & jQuery / Javascript

We are working on a project with JSF and PrimeFaces and we are looking to add dynamic inline validation on our forms. I'm not sure if PrimeFaces can handle this (correct me if I am wrong) so I am looking for some alternatives
Does anyone know of any plugins we could use to do this? Prefer something that incorporates JSF too...
I'm not a developer but a UX guy so sorry if some of the terminology is incorrect.
Standard JSF supports server side validation by ajax (live example here) and PrimeFaces definitely also supports it (live example here). You can add <f:ajax event="blur" render="message_id" /> inside input components to perform validation directly on blur (see also this tutorial).
<h:inputText id="foo" value="#{bean.foo}" required="true">
<f:ajax event="blur" render="foo_message" />
</h:inputText>
<h:message id="foo_message" for="foo" />

How to get Facebook comments count in HTML5 without using a <div>?

The Facebook comments count can be done in three different ways: (without directly using JS)
<fb:comments-count href="http://example.com" />
<iframe src="http://www.facebook.com/plugins/comments.php?href=example.com" />
<div class="fb-comments-count" data-href="http://example.com">0</div>
The issue, however, is that doing something like this messes things up:
<p><div class="fb-comments-count" data-href="http://example.com">0</div> comments</p>
...because a <div> is firstly, not valid inside a <p> tag and secondly, looks wrong (though this could be fixed with CSS).
Basically, my question is: is there a way to do the above without using a <div> (a <span> for example), bearing in mind that I want to use the HTML5 method and (if possible!) want to avoid using javascript?
Clarification: I would like to avoid writing extra JS in the page simply because the MVC view currently looks nice and clean and I would prefer to keep it that way. Obviously, I'm still including the Facebook Connect library.
So, one solution would be to use a DIV instead of a P as the outer element.