Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial commit for issue WEB-7671 Allow Handlebars/Mustache expression delimiters to be changed from the defaults #935

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions dts/src/com/intellij/dts/settings/DtsSettingsPathInput.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,22 @@ import javax.swing.plaf.basic.BasicComboBoxEditor
abstract class DtsSettingsPathInput<T>(private val disposable: Disposable?,
private val browserTitle: @NlsContexts.DialogTitle String) : ComboBox<T>() {
protected val textField = ExtendableTextField()
protected val customDelimitersField = JTextField(HbConfig.getCustomDelimiters())

var text: String by textField::text

init {
textField.border = null
configureCustomDelimitersField()
configure()
}

private fun configureCustomDelimitersField() {
customDelimitersField.addActionListener {
HbConfig.setCustomDelimiters(customDelimitersField.text)
}
}

protected fun configure() {
val editor = object : BasicComboBoxEditor() {
override fun createEditorComponent(): JTextField {
Expand All @@ -29,8 +42,8 @@ abstract class DtsSettingsPathInput<T>(private val disposable: Disposable?,
)

textField.addBrowseExtension({
listener.actionPerformed(ActionEvent(textField, ActionEvent.ACTION_PERFORMED, "action"))
}, disposable)
listener.actionPerformed(ActionEvent(textField, ActionEvent.ACTION_PERFORMED, "action"))
}, disposable)

return textField
}
Expand Down Expand Up @@ -64,4 +77,4 @@ abstract class DtsSettingsPathInput<T>(private val disposable: Disposable?,
textField.removeFocusListener(listener)
}
}
}
}
8 changes: 8 additions & 0 deletions handlebars/src/com/dmarcotte/handlebars/config/HbConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
import static com.dmarcotte.handlebars.config.Property.*;

public final class HbConfig {
public static String getCustomDelimiters() {
return getStringPropertyValue(Property.CUSTOM_DELIMITERS);
}

public static void setCustomDelimiters(String delimiters) {
setStringPropertyValue(Property.CUSTOM_DELIMITERS, delimiters);
}


public static boolean isAutoGenerateCloseTagEnabled() {
return getBooleanPropertyValue(AUTO_GENERATE_CLOSE_TAG);
Expand Down
15 changes: 15 additions & 0 deletions handlebars/src/com/dmarcotte/handlebars/config/Property.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@
* Formalizes the properties which we will persist using {@link com.intellij.ide.util.PropertiesComponent}
*/
enum Property {
CUSTOM_DELIMITERS {
@Override
public @NotNull String getStringName() {
return "handlebars.custom.delimiters";
}

@Override
public @NotNull String getDefault() {
return ""; // Default is empty string (no custom delimiters)
}

public static final String ENABLED = "enabled";
public static final String DISABLED = "disabled";
},

AUTO_GENERATE_CLOSE_TAG {
@Override
public @NotNull String getStringName() {
Expand Down