In a Sublime Text 2 snippet, how do I transform a user entered parameter ${1:Param/^\w/\u$&/}? - sublimetext2

I am trying to make a ST2 snippet to insert a comment "section" in my PHP code. I am attempting to achieve something like the following:
// --------------------------------------------------
// ${1:Enter section title here/^(.*)$/\U\1/}
// --------------------------------------------------
So that when the snippet is triggered, a user might enter "dumb loop" as $1, and it would be transformed to "DUMB LOOP".
The problem is, I am getting errors when I try to do this. Am I correct in assuming ST2 doesn't support this? The best I am able to do to achieve this right now is:
// --------------------------------------------------
// ${1/^(.*)$/\U\1/}
// --------------------------------------------------
// DELETE THIS LINE: $1
Which more or less enters junk text into the snippet because that last line is only needed to "create" parameter 1, so that it can be correctly transformed and placed where it should go.
Is there any way to transform a snippet parameter in the same place it is defined/located?! Thanks!!

Related

HTML-assigned 'id' Missing in DOM

Within the Moodle (v. 3.5.7) Atto editor (using both Chrome and Firefox) I've been trying to assign an ID to a particular row class, "span9". My ultimate objective is to assign this a unique ID and reference this element via jquery so as to append another element within it.
The ISSUE is that once I add an ID (id="checklist01") and click save, the ID simply does not appear in the DOM, and seems to not exist. When I re-enter the atto editor however, voila, there it is just sitting there. So it's NOT being removed completely... just not expressed somehow?
I have 2 screenshots linked below showing (1) the editor view, with the element and assigned ID highlighted, and (2) a screenshot of the DOM once the changes have been saved, with that same area highlighted, without the assigned ID.
Screenshots of ID Missing from DOM
Bootstrap ver. 4
So far I've tried switching the placement of the id in the atto editor (class coming first vs second after ); tried to add a "span" in front of the id (for some reason, I was desperate); and really just searched all over for someone who has encountered something similar.
I'm not sure how much help the html will provide, but here it is:
<div class="row-fluid colored">
<div class="iconbox span3">
h4>Your Completion Status (%)</h4>
</div>
<div id="checklist01" class="span9">
</div>
</div>
I found the reason for the removal of id attributes.
id attributes are removed because "Checklist" activity used safe HTML function of Moodle. If you want to access id attributes of description HTML follow below steps.
Go to mod\checklist\locallib.php file.
Then search formatted_intro() function (which is around line number 880).
In that function they used Moodle's format_text() function to return description text.
In that function, they have used 3 parameters.
string $text The text to be formatted.
int $format Identifier of the text format to be used
object/array $options text formatting options
Replace
$opts = array('trusted' => $CFG->enabletrusttext);
to
$opts = array('trusted' => $CFG->enabletrusttext,'allowid'=>true);
Then save your file and check. By following the above steps you can use id attributes.

How to add auto-complete Sublime Text 3

I would like to add custom auto-complete key bindings much like built-in:
Example: html+tab auto-completes the Doctype Block.
I tried adding html custom key binding: type c + o + l + tab to generate <div class="col-">
Preferences > Key Bindings > Default (OSX).sublime-keymap -- User
{"keys": ["c+o+l+tab"], "command": "insert_snippet", "args": {"contents": "<div class=\"col-$0\">"}},
However, two issues:
the new key binding overrides all other auto completes
the initial col or characters remains in front of the
generated tag. col<div class="col-">
What is the correct way to add this type of key binding?
The correct way to do something like this is to use either snippets or completions. Although there are some differences, generally speaking they both work the same way in the end, and which one you choose depends on how many such items you want to create and how complex you want them to be.
Using a snippet, you would select Tools > Developer > New Snippet... from the menu and fill out the snippet template, then save it as a sublime-snippet file in the location that Sublime defaults to (which is your User package).
For example, that might look like the following based on the example in your question:
<snippet>
<content><![CDATA[
<div class="col-$0">
]]></content>
<description>Insert DIV with column class</description>
<tabTrigger>col</tabTrigger>
<scope>text.html</scope>
</snippet>
Snippets are XML formatted, and everything between ![CDATA[ and ]] is inserted into the buffer (don't remove the CDATA even if you think you don't need it; Sublime will ignore the snippet if you do).
The tabTrigger specifies the text that you want to be the trigger for the snippet, the scope says what sort of files the snippet should trigger in, and the description will be displayed next to the snippet in the auto-completions panel.
In a snippet, the tabTrigger, scope and description are all optional. If you don't specify a tabTrigger you can only expand the snippet from the Command Palette or via the insert_snippet command (for example in a key binding). Without a scope the snippet applies everywhere, and without description it has no description in the panel.
If you have many such items that you want to add snippets for, you can also use completions instead. These are stored in JSON files with an extension of sublime-completions and should be saved in your User package (use Preferences > Browse Packages... if you don't know where that is.
An example of such a file would be:
{
"scope": "text.html",
"completions": [
{ "trigger": "col\tInsert DIV with column class", "contents": "<div class=\"col-$0\">" },
]
}
In this format, the trigger is always the text to trigger and the description (still optional) is separated from the trigger by a \t character in the trigger key.
In completions you only specify the scope once at the top instead of every time, but there are some functional differences between completions and snippets.
There can only be one snippet per sublime-snippet file, but a sublime-completions file can contain many completions in a single file; the completions key is an array so you can place more than one completion in the same file.
Completions are JSON, so contents that are multi line or contain JSON specific characters such as a " character are harder to enter; completions are better for shorter sequences while snippets are better for more complex things.
When autocomplete triggers, if there is a completion and a snippet that could be autocompleted, snipptets always "win" and are inserted, whereas completions cycle. That means that for example in this particular example you need to press Tab twice because col is also the name of a tag.
Snippets automatically appear in the command palette (when they apply) but completions do not. In the command palette, Snippets appear as commands like Snippet: Something, where Something is the description if it exists and the name of the file if it does not.
In either case, you can make the snippet/completion apply only in certain types of files by applying a scope; to determine the appropriate scope, position the cursor in a file at the appropriate place and select Tools > Developer > Show Scope Name...; the more of the displayed scope you use the more specific it becomes. Generally just the top level such as text.html is all that's needed unless you're doing something special.

How to remove text from order summary in Prestashop

As shown in screenshot there are 4 lines in the order summary but we want to remove 3rd line from this summary.
However i know we can change the text from translations but don't know how to remove.
You have to edit the right file for the payment method, in your case is the bankwire module.
If you have the default template go to prestashop/themes/default-bootstrap/modules/bankwire/views/templates/front/ and edit this file
payment_execution.tpl.
This file is in smarty code, specifically you have to remove this line code:
- {l s='Bank wire account information will be displayed on the next page.' mod='bankwire'}

Receiving click events from separate lines with AS3

I want to receive separate click events from separate lines in a text field, and every time a certain line is clicked by the user, I would like to highlight it and have an event happen.
I would ideally like this to happen with dynamic text, and not have to break the text apart by hand. Using the htmlText property is an option, but I am unsure as to how to bind clickEvents to separate elements.
Where do I begin?
There is no ready to use solution for this. But you can make it yourself using a few things:
set CLICK listener for the whole text field
listen for click and check the caretIndex property
use getLineIndexOfChar to check what's the line of the current caret position
use getLineOffset and getLineLength to get the position of the first and last character of that line
use setSelection to highlight this line
There might be some faster and easier way, but this is what works for sure :)
EDIT: decided to post the solution code, as I was wondering how exactly it works.. and it would be a shame to just leave it unpublished and make you do it instead :)
field.addEventListener(MouseEvent.CLICK, onTfClicked);
function onTfClicked(e:MouseEvent):void {
trace (field.caretIndex);
var line:uint = field.getLineIndexOfChar(field.caretIndex);
var start:uint = field.getLineOffset(line);
var end:uint = start + field.getLineLength(line);
field.setSelection(start, end);
}

Prevent execution of script in a View when writing html tags

I have two html strings:
<script type="text/javascript">alert("s");</script>
1<br>2<br>3
User enters these and I store then in my database. Then, I load theme from the database again and write theme in a view to show theme to the user.
Here's how I do it:
// 1
#MvcHtmlString.Create("<script type="text/javascript">alert("s");</script>");
// 2
#MvcHtmlString.Create("1<br>2<br>3");
And, here is the results on my view:
1. A javascript dialog box pops up and shows the alert to the user.
2. 1
2
3
In sample 1, user can enter a script and bring up a javascript alert and the user can see the following string:
"<script type="text/javascript">alert("s");</script>"
That is OK, but in sample 2, the <br> tag does not work, and user will see this:
1<br>2<br>3
What can I do to have these outputs:
1: "<script type="text/javascript">alert("s");</script>"
2: 1
2
3
Note that I do not want to remove any part of user's data, because if a user is a developer and wants to show a script syntax, he should be allowed to.
There are many ways to do this, i like to use #Html.Raw
#Html.Raw("1<br>2<br>3")
for displaying html, and the output will be
1
2
3
#Html.Raw("<script>alert('s');</script>").ToHtmlString()
for displaying text , by adding ToHtmlString() , and the output will be
<script>alert('s');</script>