Implement an if/else using TYPO3 templates syntax - typo3

Is there a way to to implement IF/ELSE using TYPO3 templates syntax?
Here is my template:
<div class="simi-prof-pic">
<div class="simi-botcurv">###ITEM_IMAGE###</div>
</div>
I would like it to work this way (written using PHP syntax):
<?php if(###ITEM_IMAGE###):?>
<div class="simi-prof-pic">
<div class="simi-botcurv">###ITEM_IMAGE###</div>
</div>
<?php else: ?>
NO IMAGE
<?php endif;?>

If you're implementing an extension you downloaded you're pretty much stuck with what you get and the templating engine you're describing is a simple search and replace mechanism which cannot be extended, cannot implement much presentation logic and will not interpret PHP.
If, however, you're writing your own module you can implement any of the alternative templating engines available for TYPO3, for example:
http://flow3.typo3.org/documentation/manuals/fluid/
http://typo3.org/extensions/repository/view/smarty/current/

Related

Is using <div class="col-sm-6"> or <b-col sm="6"> the same?

I just started looking into bootstrap-vue (and vue actually) and I noticed that <b-col sm="6"> translates into the classic <div class="col-sm-6"> so I wonder if there is any difference or advantages in using <b-col sm="6">.
Most web designers are confortable in using <div class="col-sm-6"> so why asking them to switch to the other notation?
There is no difference but only more convenient to use.
By setting sm="6" as a property, you can more easily change the value (dynamic) without needing a jquery but purely a js function within Vue. With this you make full use of Vue which is a lot easier to see.
:sm="getColSize"
Can be anything you want. With classes i find it more effort.
<b-col> (and the other layout helper components) are purely for convenience, as they require less typing (expecially for complex colums that have different width at different breakpoints).
They are written as Vue functional components (they keep no state information), so render fast.
You can be free to mix and match with regular html markup for layout, or not use them at all.

Best practice for ion tags

I am a bit confused about tag usage in the ionic framework. If you check their docs under CSS components, you'll see they use existing tags (particularly div) with a specific class choice to achieve formatting, just like you'd expect from something like bootstrap. Example:
<div class="bar bar-header bar-light">
<h1 class="title">bar-light</h1>
</div>
If you go by their code samples, however, you see that they use custom ion tags instead. Example:
<ion-header-bar class="bar-assertive">
<h1 class="title">Left Menu</h1>
</ion-header-bar>
The same practice of using custom ion tags is used in their guide as well as a pluralsight tutorial I found on ionic.
So what's going on here? If both approaches accomplish the same thing, which one is considered best practice?
Ionic Framework, as stated in their site, is:
Ionic is both a CSS framework and a Javascript UI library. Many
components need Javascript in order to produce magic, though often
components can easily be used without coding through framework
extensions such as our AngularIonic extensions.
Using CSS Components you're simply applying CSS styling to your HTML page.
When using the Ionic directives you're using a fully-featured JavaScript component and you have access to the APIs provided by the framework.
To better understand the difference you should dig into AngularJs directives.
Take the list for example. You could create a simple list using an HTML ul li:
<ul class="list">
<li class="item">
...
</li>
</ul>
but if you use the directive:
<ion-list>
<ion-item ng-repeat="item in items">
Hello, {{item}}!
</ion-item>
</ion-list>
you have access to the extended features provided by the framework (see the API at the bottom of the page).
I tend to use directives most of the times unless I know I don't want any kind of interaction with the interface.

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.