Jetbrains Goland HTML Templates Formatting and Code Completion - go

I am using Go HTML Templates in Jetbrains Goland. How do I get all 3: HTML formatting, template code completion, and template formatting for templates?
Assuming I installed Go Templates plugin and I am using "*.tpl" as a file extension for my templates, I have two options:
Settings - Editor - Filetypes - HTML - Add "*.tpl" as an HTML type.
PROS: I have an HTML code completion and syntax highlighting with a caveat (see CON 2)
CON 1: I do not have code completion on template items, the editor is unaware of templates at all
CON 2: Template code blocks are treated as text, i.e. I do not have code indentation for RANGE blocks for example when I try to format my code.
Settings - Editor - Filetypes - Go Templates - Add "*.tpl" as registered type with "HTML" as an underlying type ("Template data language")
PROS: I have code completion for 'dots' and can see properties and methods on them (see https://www.jetbrains.com/help/go/integration-with-go-templates.html)
CONS: No HTML highlighting, autocompletion, or formatting...

After hours of research, I finally found the answer:
Settings - Languages and Frameworks - Template Data Languages - Project Language - Set "HTML"
Also, I suggest using "*.go.html" as a Go Templates extension. This way you can see syntax highlighting even when opening the template in VSCode, online on GitHub, etc.

Related

Go text template syntax highlighting in GoLand

GoLand has syntax support on Go html files with the file extension of .gohtml
So what about Go text files? Does GoLand support that as well? .tmpl is supported by vim-go but not GoLand.
As mkopriva has already hinted and you have described as well in the comments, you can go to Preferences/Editor/File Types and add your custom ending as Registered pattern to the Go Template. But imo the real game changer is that you can also set Go as Template data language there. This way even the Go syntax gets validated, not just the template syntax. It's still wonky, but definitly better than nothing.
Still, autoformatting does not work properly and can screw up your code. Therefore, you might also want to make sure the Reformat code in the commit dialog is unchecked. Same with Optimize Imports ... better keep it unchecked.
there are two parts to this answer to get both html highlighting and go template highlighting
go template highlighting:
settings > editor > file types > select Go template files from the list > update pattern to the file ending you use for your go templates. I used *.go.html
html highlighting
settings > template data languages > project language (dropdown at the top) > set to html
now you have both html highlighting and go template completion

Is there an editor (or a solution for kate) doing syntax highlighting in a mixed code?

I'm using Kate as the editor of my Node.js projects. In the Node.js projects, I sometimes prefer to code whole index.html in a single file. At that time, I need to use:
html
css (<style>...</style>)
livescript (<script type="text/ls">...</script>)
javascript (<script [type="text/javascript"]>...</script>)
at the same time. Kate can highlight these codes if they are in their separate files.
How can I make the code highlighted correctly when they are mixed in a single file (preferably in Kate, or any other editor that would run on Linux)?
Kate can do this, too. It is supported in e.g. HTML/PHP highlighting and similar. Just have a look into the respective highlighting xml files to get an idea how to implement a highlighting for this. More information about how to write syntax highlighting files can be found in the KatePart Handbook.

How to get Smarty Template Highlighting in Zend Studio 9?

I am trying to find a way to get smarty templates, .tpl files, to work with Zend Studio 9. The smartypdt plugin fails to install on Mac OS, and all the other File Associations--I have tried PHP Editor and HTML as associated editor--fail, too. This time stating: "Unsupported content type in editor". So all I am left with is a plain text mode.
How do I get basic template highlighting? I do not necessarily want smarty support anymore, just basic HTML and JavaScript highlighting would be enough.
On the File Associations Panel, there is a link to Content Types. There, I have added *.tpl file to the HTML view node. This ensures basic html highlighting and goes a long way when compared to the plain text mode.

Integrated Markdown WYSIWYG text editor

In looking for a straightforward WYSIWYG editor for Markdown code, I am not finding a comparible UI to that of CkEditor, TinyMCE, ect.
Specifically, the Markdown "WYSIWYG" editors that are often recommended (such as posts like this ) are not pure WYSIWYG editors in the sense that users either still write raw Markdown ( MarkItUp ) or go to the other extreme of having in-line editing without standard controls ( Hallo ).
I need something in-between.
I'm looking for a Markdown editor that looks and functions like a stripped down CkEditor text box, and that accepts and outputs Markdown. There should be a toolbar with a minimum set of formatting options (B, I, U, lists, ect), and the text entry area should show the converted Markdown, not the raw code. There should be a Source button that will allow users to edit the raw Markdown, but even that is optional. Ex:
I get the reason for Markdown/wiki, ect - the security it offers. I don't mind entering raw code like here at SE, but my users are not geeks and do not find this enjoyable. They don't want to see * * * ___ and spaces mixed in with their text. They are used to "Word" style editing, and are most productive in that environment.
So - is there a truly integrated WYSIWYG editor for Markdown? I'm writing in a PHP, so something that I can invoke with a class would be perfect.
Sept 23, 2015 Update
CKEditor now has a Markdown addon that does this exact thing. The addon project is hosted on github.
Screenshots:
Apr 13, 2015 Update
Someone professing to develop CKEditor says that the appearance of CommonMark is a game changer, and we could possibly see a proper markup interface for CKEditor (read comments for the full story).
Feb 6, 2015 Update
CKEditor now comes with a plugin that outputs (and accepts as input) BBCode.
Demo: http://ckeditor.com/demo#bbcode
SimpleMDE, a newcomer, may be the answer. I've been searching for something just like this for a month now. I'm surprised that this does not show up higher in search results. I had to go through a notice on lepture/editor to find this.
I was researching in this subject the other day and I haven't found any decent WYSIWYG editor with Markdown output. In fact, first you have to have to create a WYSIWG Markdown editor is WYSIWG HTML editor and there are just few of them that are usable on the market.
There's a chance that you'll be able to create dataProcessor for CKEditor that will change HTML editor into Markdown editor. We've got a plugin for BBCode that works like this (check out http://nightly-v4.ckeditor.com/3737/samples/bbcode.html).
All you have to do is implement this interface http://nightly-v4.ckeditor.com/ckeditor_api/#!/api/CKEDITOR.dataProcessor. If you check BBCode plugin's code you'll see some hacks and tricks, because unfortunately current CKEditor's architecture isn't ready (yet) to create such a data processor. However, I believe that if you want to provide only few styling options you should be able to implement Markdown support pretty quickly.
EDIT Sept 23, 2015
CKEditor now has a Markdown addon that does this exact thing. The addon project is hosted on github.
Screenshots:
As posted in my Feb 6, 2015 update, CKEditor now includes plugins that allow BBCode input and output.
A demo is available here: http://ckeditor.com/demo#bbcode
EDIT Apr 13, 2015:
Someone professing to develop CKEditor says that the appearance of CommonMark is a game changer, and we could possibly see a proper markup interface for CKEditor (read comments for the full story).
Pen is a new (active as of 2014) WYSIWYG editor that outputs Markdown.
It's not perfect—I've had issues with pasting HTML there—but it works.
Edit: Sorry! It doesn't output Markdown. Walery Strauch pointed out in the comments that the Markdown formatting signs I saw were actually CSS pseudo element rules:
Still, I'll leave it here as an option since some people upvoted this answer and it may have been of use to somebody.
I implemented a very simple editor that allows the contents of a <textarea> that contains Markdown to be edited in a WYSIWYG fashion.
I used Hallo. I don't think its web site makes it obvious that it is not itself a Markdown WYSIWYG editor but the demo does forge the path to one.
Hallo allows WYSIWYG editing of the HTML inside a <div>. I used javascript to hide any <textarea> blocks that have a specific wysiwyg CSS class, replacing it with a <div> and copying the contents of the <textarea> into the <div>. The copying runs through Showdown which produces HTML from Markdown.
Another Javascript routine reacts every time the <div> contents change. It copies the contents back into the (now hidden) <textarea>. The content is run through to-markdown to convert from HTML to Markdown.
If the <textarea> is a field in a <form>, then the edited Markdown will be sent to the server when that form is submitted.
The inspiration for this comes from the Hallo Markdown Example, specifically the editor.js file. I used that as a basis for my own script along with hallo.js, showdown.js and to-markdown.js.
My script, wysiwyg.js is a derivative of editor.js from the Hallo Markdown Example. Some points to note:
I use this in a Rails application (not that that matters)
It runs on ready and also on page:load, the latter because Rails uses Turbolinks
It runs on ajaxComplete because I use Ajax for form error reports
There are other dependencies: JQueryUI and Rangy (Rails users can avail of the gems jquery-ui-rails and rangy-rails).
Also Font Awesome is used for the tool bar icons. The version of hallo.js used by the demo is out of date (it uses an old version of Font Awesome) - use hallo.js from GitHub instead.
You only need to add CSS class='wysiwyg' to any <textarea> to enable WYSIWYG on it. The <textarea> should conain Markdown formatted text.
I would expect that wysiwyg.js could be easily adapted to use another editor if you don't like Hallo as long as it works on the HTML in a <div>. There are quite a few to choose from but not all are as lightweight as Hallo.
A smilar piece of work that I found is markdown-html-form. It uses the same Showdown and to-markdown.
I am also looking for a markdown editor that is described at the top of this thread
Have you seen "markdown tools": http://md-wysiwyg.sourceforge.net/
Demo: http://md-wysiwyg.sourceforge.net/cgi-bin/cgi_wysiwyg_test.py/
That seems pretty close to what we are looking for, it does a reasonable job of taking your WYSIWYG rich text and outputting markdown. However it failed on an encoding exception when I pasted in some rich text from a google doc.
I found two which currently seem to be quite popular, active and free but haven't been mentioned yet.
The first one is Toast UI Editor. It supports both modes (WYSIWYG and raw). It has official react and vuejs wrappers.
The second one is ProseMirror which calls itself "a toolkit for building rich-text editors on the web" and it seems to be very flexible and extensive. It also supports both modes.
I'm pretty sure solid unofficial react / vue / angular wrappers for it can be found as well.

What is the best way to debug Typoscript in TYPO3 CMS?

What is the best way to debug typoscript in the TYPO3 CMS?
Assuming I have a list, which is not displayed -
what is the strategy to look for the issue?
Debugging Typoscript is not the most comfortable task, but there are several possibilities. Here are the most common techniques:
Use the TS Object Browser in the backend: Choose the Web > Template module, then pick the page from the pagetree you need to debug. If there are any obvious syntax errors or redundant/missing brackets, an error message will be displayed. Switch between constants and setup and use the search field extensively. In your example, search for the myListview parameter if your TypoScript object is named myListview.
Use the Template Analyzer in the backend (also in Template module): It's similar to the Object Browser, but the Template Analyzer gives you valuable insights where in your setup the errors (or warnings) exactly are that have been spotted.
Outsource your Typoscript setup (+ constants) to files, then use a syntax highlighter in your favorite text editor. You get a better overview and the highlighting helps to avoid misspellings. For example:
PhpStorm TypoScript plugin (recommended combo)
Netbeans TypoScript plugin
Eclipse / Aptana: DEV3
Coda: ts4c
Textmate: Textmate Typoscript bundle
PSPad: sweeTS
jEdit: jEdit plugin
Sublime Text: Textmate Typoscript bundle
Activate the admin panel in the frontend and use the section "TypoScript". It shows you selected rendered (config) values, SQL queries, error messages and more. However, it's not complete and I'm not using it frequently so I am also keen on knowing more about it.
Wrap your Typoscript objects with the stdWrap.debugFunc Function or use the build-in debugItemConf method for all MENU objects. Debug output will be seen in the frontend. Read more in the TYPO3 Wiki
Most common errors (apart from typos) are wrong file paths, non-existing HTML-templates or missing subparts in modified templates. Also, forgetting to include static templates for an extension might leave the intermediate user puzzled. Just as a starting point :).
Hope that helps, please post any additions into the comments.
The most important thing is, not to rely on code you found via google. Have a look into TSref and check what is possible.
Just some little additions which are easy to overlook (IMHO):
The template analyser has an option: "View the complete TS Listing", so can search in the whole created typoscript! Including conditions.
TS Object Browser: you can check conditions to simulate different situations
If you need to debug TypoScript configuration in the backend, go to the "Info"-Modul, select a page in the page tree and then select "Page TSconfig" in the main window. There you will get a info about Page TS Config.
These system extensions are usually installed, but they can be deactivated:
tstemplate
tstemplate_ceditor
tstemplate_info
tstemplate_objbrowser
tstemplate_analyzer
info_pagetsconfig (info modul)
tsconfig_help (addition to the info modul)
It may happen, that someone else just deactivated them.
SIMPLE: use headerData in typoscript and view source code by this you can debug typoscript.

Resources