<commit_before>package org.codehaus.groovy.grails.web.sitemesh

import org.codehaus.groovy.grails.web.taglib.AbstractGrailsTagTests

/**
 * Tests the sitemesh capturing and rendering tags end-to-end
 *
 * @author <NAME>
 * @since 1.2
 */

public class FullSitemeshLifeCycleTests extends AbstractGrailsTagTests{

    void testSimpleLayout() {
        def template = '''
<html>
		<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>This is the title</title></head>
		<body onload="test();">body text</body>
</html>
'''

        assertOutputEquals '''
<html>
		<head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/><title>This is the title</title></head>
		<body onload="test();">body text</body>
</html>
''', template
        
        def layout = '''
<html>
    <head><title>Decorated <g:layoutTitle /></title><g:layoutHead /></head>
    <body><h1>Hello</h1><g:layoutBody /></body>
</html>
'''
         def result = applyLayout(layout, template)

        assertEquals '''
<html>
    <head><title>Decorated This is the title</title><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/></head>
    <body><h1>Hello</h1>body text</body>
</html>
''', result
    }


    void testParameters() {
        def template = '''
<html>
  <head>
      <title>Simple GSP page</title>
      <meta name="layout" content="main"/>
      <parameter name="navigation" value="here!"/>
  </head>
  <body>Place your content here</body>
</html>
'''

        def layout = '<h1>pageProperty: ${pageProperty(name: \'page.navigation\')}</h1>'

        def result = applyLayout(layout, template)

        assertEquals '<h1>pageProperty: here!</h1>', result 
    }
}<commit_msg>test for GRAILS-5204 "Sitemesh pageProperty not working"<commit_after>package org.codehaus.groovy.grails.web.sitemesh

import org.codehaus.groovy.grails.web.taglib.AbstractGrailsTagTests

/**
 * Tests the sitemesh capturing and rendering tags end-to-end
 *
 * @author <NAME>
 * @since 1.2
 */

public class FullSitemeshLifeCycleTests extends AbstractGrailsTagTests{

    void testSimpleLayout() {
        def template = '''
<html>
		<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>This is the title</title></head>
		<body onload="test();">body text</body>
</html>
'''

        assertOutputEquals '''
<html>
		<head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/><title>This is the title</title></head>
		<body onload="test();">body text</body>
</html>
''', template
        
        def layout = '''
<html>
    <head><title>Decorated <g:layoutTitle /></title><g:layoutHead /></head>
    <body><h1>Hello</h1><g:layoutBody /></body>
</html>
'''
         def result = applyLayout(layout, template)

        assertEquals '''
<html>
    <head><title>Decorated This is the title</title><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/></head>
    <body><h1>Hello</h1>body text</body>
</html>
''', result
    }


    void testParameters() {
        def template = '''
<html>
  <head>
      <title>Simple GSP page</title>
      <meta name="layout" content="main"/>
      <parameter name="navigation" value="here!"/>
  </head>
  <body>Place your content here</body>
</html>
'''

        def layout = '<h1>pageProperty: ${pageProperty(name: \'page.navigation\')}</h1>'

        def result = applyLayout(layout, template)

        assertEquals '<h1>pageProperty: here!</h1>', result 
    }


    void testParametersWithLogic() {
        def template = '''
<html>
  <head>
      <title>Simple GSP page</title>
      <meta name="layout" content="main"/>
      <parameter name="sideBarSetting" value="vendor"/>
  </head>
  <body>Place your content here</body>
</html>
'''
        def layout = '''<g:if test="${pageProperty(name:'page.sideBarSetting') == 'vendor'}">good</g:if>'''

        def result = applyLayout(layout, template)

        assertEquals 'good', result 

    }
}
{'fraction_non_alphanumeric': 0.1797211660329531, 'fraction_numerical': 0.0076045627376425855, 'mean_word_length': 3.615204678362573, 'pattern_counts': {'":': 0, '<': 129, '<?xml version=': 0, '>': 129, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1223149', 'n_tokens_mistral': 1319, 'n_tokens_neox': 1259, 'n_words': 265}