
com.github.heneke.thymeleaf.togglz.processor.FeatureInactiveAttrProcessor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of thymeleaf-extras-togglz Show documentation
Show all versions of thymeleaf-extras-togglz Show documentation
Thymeleaf dialect integrating Togglz feature toggles.
The newest version!
/*
* =============================================================================
*
* Copyright (c) 2014, Hendrik Heneke
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* =============================================================================
*/
package com.github.heneke.thymeleaf.togglz.processor;
import org.thymeleaf.context.ITemplateContext;
import org.thymeleaf.engine.AttributeName;
import org.thymeleaf.model.IProcessableElementTag;
import org.thymeleaf.standard.processor.StandardIfTagProcessor;
import com.github.heneke.thymeleaf.togglz.TogglzDialect;
import org.thymeleaf.templatemode.TemplateMode;
/**
* Processor for the inactive
attribute in {@link TogglzDialect}. It shows or hides the given DOM container
* based on feature state:
*
*
*
* <span togglz:inactive="FEATURE">
* Only visible when FEATURE is inactive.
* </span>
*
*
* Features may also be specified dynamically by using expressions:
*
*
*
* <span togglz:inactive="${feature}">
* Only visible when feature resolved by evaluating ${feature} is inactive.
* </span>
*
*
* When using Thymeleaf 2.0.x, literal feature names have to be quoted with single quotes. Thymeleaf from 2.1 onward
* supports unquoted string literals.
*
* @author Hendrik Heneke
* @since 1.0.1
*/
public class FeatureInactiveAttrProcessor extends AbstractFeatureAttrProcessor {
public static final String ATTR_NAME = "inactive";
public static final int ATTR_PRECEDENCE = StandardIfTagProcessor.PRECEDENCE;
public FeatureInactiveAttrProcessor(final TemplateMode templateMode, String dialectPrefix) {
super(templateMode, dialectPrefix, ATTR_NAME, ATTR_PRECEDENCE);
}
@Override
protected boolean isVisible(final ITemplateContext context, final IProcessableElementTag tag, final AttributeName attributeName, final String attributeValue) {
return !determineFeatureState(context, tag, attributeName, attributeValue, true);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy