I have some components that I've broken into multiple smaller files. The main file includes them using data-sly-include attributes.
I'd like to generate HTML comments containing the current filename in both the main file and the included files, so that when I view the rendered output I can easily tell which file generated the output. Something like:
... some HTML from the template or other components...
<!-- begin /path/to/main/file.html -->
<div>
This is from the main file
<!-- begin /path/to/main/includes/first.html -->
<p>This is fromt the first include</p>
<!-- end /path/to/main/includes/first.html -->
<!-- begin /path/to/main/includes/second.html -->
<p>This is fromt the second include</p>
<!-- end /path/to/main/includes/second.html -->
now we're back in the main file
<!-- end /path/to/main/file.html -->
I can see how to get the path to the current page, but that's the resource that contains my component; I want the paths to the files that make up the components. Any way to do this in Sightly?
the sightly script engine has the current file as a binding variable with sling, so the following should work-
sling.getScript().getScriptResource().getPath()
you will have to put this in a js file and call it from all your sightly scripts.
Related
I have been working on a Drupal 8 theme using views module. For some reason, the module fails to display the list of file name suggestions.
At first I believed that the problem was sole in displaying the suggestions. However, after creating a new template file, following the pattern (views-view-unformatted--news-article-listings.html.twig), and rebuilding the cache, the file is ignored.
The picture bellow is the output of the twig file with debugging turned on.
Any ideas?
I know this is an old issue, but readers may be interested in this issue
https://www.drupal.org/project/drupal/issues/2923634#comment-12417950
Core Views does not currently supply theme suggestions in Drupal 8
The fix is being worked on, but the patch in #8 worked for me (v 8.5.5), and I can now see views theme suggestionsÂ
I think that theme suggestions from views module are buggy. Now Im doing project, where there is none of them:
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'block' -->
<!-- FILE NAME SUGGESTIONS:
* block--mdb-content.html.twig
* block--system-main-block.html.twig
* block--system.html.twig
x block.html.twig
-->
<!-- BEGIN OUTPUT from 'themes/mdb/templates/block/block.html.twig' -->
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'container' -->
<!-- BEGIN OUTPUT from 'core/themes/stable/templates/form/container.html.twig' -->
<div class="views-element-container">
<!-- THEME DEBUG -->
<!-- THEME HOOK: 'views_view' -->
<!-- BEGIN OUTPUT from 'core/themes/stable/templates/views/views-view.html.twig' -->
<div class="wrapper js-view-dom-id-8f70d5c8af23f92729c2180de609f1a2df672d7711b56b0a606853692ee787cd">
You can see, that file name suggestions works well on top, but under views_view hook i dont see any. But we can remember how they should look from Drupal 8 documentation:
View, named foobar. Style: unformatted. Row style: Fields. Display: Page.
views-view--foobar--page.html.twig
views-view--page.html.twig
views-view--foobar.html.twig
views-view.html.twig
views-view-unformatted--foobar--page.html.twig
views-view-unformatted--page.html.twig
views-view-unformatted--foobar.html.twig
views-view-unformatted.html.twig
views-view-fields--foobar--page.html.twig
views-view-fields--page.html.twig
views-view-fields--foobar.html.twig
views-view-fields.html.twig
https://api.drupal.org/api/drupal/core%21modules%21views%21views.theme.inc/group/views_templates/8.2.x
I am using the ZK framework and have created a maven project of custom components.
I am trying to include static CSS for the project (for components with no javascript) as per the brief outline on this page:
http://books.zkoss.org/wiki/ZK_Component_Development_Essentials/Packing_as_a_Jar
How does zk know to include the CSS generated when the project is included in a ZK WEB project ? Currently my resources directory of my component project looks like this:
web
foo
bar
css
zk.wcs
macro.css.dsp
other.css.dsp
less
macro.less
other.less
My zk.wcs :
<css language="xul/html">
<stylesheet href="~./foo/bar/css/macro.css.dsp"/>
<stylesheet href="~./foo/bar/css/primitive.css.dsp"/>
</css>
My styles in macro.css.dsp are not applied when using the component project in my web zk project however...
You can include css in lang-addon.xml:
<!-- define a component -->
<component>
<!-- the tag name of this component
required,
must be unique -->
<component-name>codemirror</component-name>
<!-- fully-qualified java class name at server side
required for a new component that not extends another component -->
<component-class>org.sinnlabs.zk.ui.CodeMirror</component-class>
<!-- widget class, 'org.sinnlabs.zk.ui.CodeMirror' also specify the
package of widget class 'org.sinnlabs.zk.ui'
required for a new component that not extends another component -->
<widget-class>org.sinnlabs.zk.ui.CodeMirrorWidget</widget-class>
<!-- mold
required for a new component that not extends another component
or has self widget-class
a mold denotes the files that to render and style this comopnent -->
<mold>
<!-- default mold is required -->
<mold-name>default</mold-name>
<!-- relative path based on widget-class' path
(web/js/org/sinnlabs/zk/ui/)
where codemirrorwidget.js (required) contains a function that
will render the html of the comopnent. -->
<mold-uri>mold/codemirrorwidget.js</mold-uri>
<css-uri>css/codemirror.css</css-uri>
</mold>
</component>
zk.load will load your css style.
Suppose I have files vendor/lib.js and index.html in my PWD. I am adding a script tag to index.html (cursor position denoted by |):
....
<script src="vendor/|"></script>
....
Then I hit C-TAB and the string "vendor/" gets completed to "vendor/lib.js" (or suggestions are shown if there is ambiguity).
More formally, I want this functionality to be available for several attributes of the specific set of tags. For example, <script src=""/>, <a href=""/>, <link href=""/>, <img src=""/>, and so on.
Is there a minor mode for that? If there is no, I will appreciate any insights on how it can be implemented.
I am having problem with autocomplete mode with dhtmlx combo.
The includes files are as follows:
// Images
<script>
window.dhx_globalImgPath="combo/dhtmlxCombo/codebase/imgs/";
</script>
// CSS
<link rel="stylesheet" type="text/css" href="combo/dhtmlxCombo/codebase/dhtmlxcombo.css">
// Required JS files
<script src="combo/dhtmlxCombo/codebase/dhtmlxcommon.js"></script>
<script src="combo/dhtmlxCombo/codebase/dhtmlxcombo.js"></script>
<script src="combo/dhtmlxCombo/codebase/ext/dhtmlxcombo_extra.js"></script>
I have no issues with the code above and works well.
The following code I have on the page I have the combo itself is as follows:
<!-- HTML Combo -->
<div id="pickup" style="width:260px;"></div>
<!-- Initialisation of combo -->
<script>
var x = new dhtmlXCombo("pickup",260,"image");
// this works
x.loadXML("list.xml");
x.enableFilteringMode(true);
</script>
My problem is i want to use autocomplete mode by using the following line of code:
x.enableFilteringMode(true, "list.xml", true, true)
When i try the above line, it doesnt give error but it doesnt filter either. However im told to use a php file but i don't know what I need to put in the list.php file itself. I can code just dont know what to put in. Can anyone shed some light, the docs arent that helpful.
enableFilteringMode enables server-side filtering. It means that when you type something in the combo header, this text is sent to the script that is defined the second parameter of the method. The script generates XML with options that correspond the mask.
Therefore, you can't use static XML in this case.
You can find a demo of the dynamic loading in the dhtmlxCombo package:
dhtmlxCombo/samples/04_filtering/01_combo_big_db.html
Also, you can use dhtmlxConnector that provides a ready solutions for the server side (PHP, ASP.NET, etc.). The dhtmlxConnector package includes a demo with dhtmlxCombo, e.g.:
dhtmlxConnector_php_v10_110725/php/samples/combo/02_sql.html
I've added the following new Eclipse template via extension point. It simply adds a template for a sample testTag tag.
<!-- Add code template -->
<extension point="org.eclipse.ui.editors.templates">
<template autoinsert="true"
contextTypeId="html_tag"
description="[Description] Template populated by Snippet values ***"
id="org.eclipse.jst.jsf.ui.newHtmltag"
name="testTag">
<pattern>
<![CDATA[
<testTag style="background: ${color}"></testTag>
]]>
</pattern>
</template>
<resolver
contextTypeId="html_tag"
type="src"
class="TestTagTemplateVariableResolver">
</resolver>
</extension>
What I'd cannot figure out is how to change the value of the $(color) variable at runtime. More specifically, when the user presses Ctrl + Space (or the equivalent for content-assist) and types in "testTag" and presses Enter -- instead of the "color" placeholder text, I'd like it replaced by some other text value I have in another class. How do I do this?
This email chain from 2004 says it might not be possible:
the Java editor chooses not to respect resolvers contributed to its two context types ('java' and 'javadoc'), but only recognizes the built-in resolvers.
The html editor you are working with may have a similar restriction.