lift / lift/framework

HtmlProperties setDoctype has no effect as htmlOutputHeader calls the original doctype

Open
#1,194 1 comment 0 reactions 1 assignee View on GitHub

@dpp is already working on this.

Since Mar 1, 2012.

P:Normal
Dominant language
Scala
Stars
1.3k
Forks
275
PR merge metrics
No merged PRs in 30d

Description

as discussed on http://groups.google.com/group/liftweb/browse_thread/thread/6a0701b47e2200bc/80f0199bae1391c3#80f0199bae1391c3

I cooked up a proposed solution, see the trait "BaseType".

It only needs specs2

This pattern should work with the current way HtmlProperties works.



import org.specs2.mutable._

trait OldBaseType {

  def First: String

  def setFirst(newFirst: () => String) = {
    val old = this
    new OldBaseType {
      def First = newFirst()

      def Second = old.Second

      def Third = old.Third
    }
  }

  def Second: String

  def setSecond(newSecond: () => String) = {
    val old = this
    new OldBaseType {
      def First = old.First

      def Second = newSecond()

      def Third = old.Third
    }
  }

  def Third: String

  def setThird(newThird: () => String) = {
    val old = this
    new OldBaseType {
      def First = old.First

      def Second = old.Second

      def Third = newThird()
    }
  }
}

case class OldTestType(param: String) extends OldBaseType {
  def First =
    "HELLO"

  def Second =
    this.First + " WORLD"

  def Third =
    this.First + " " + this.Second + "!!!"
}

trait BaseType {

  def First(me:BaseType): String
  
  def First: String = First(this)

  def setFirst(newFirst: () => String) = {
    val old = this
    new BaseType {
      def First(me:BaseType) = old.First(me)
      
      override def First = newFirst()

      def Second(me:BaseType) = old.Second(me)

      def Third(me:BaseType) = old.Third(me)
    }
  }

  def Second(me:BaseType): String

  def Second: String = Second(this)

  def setSecond(newSecond: () => String) = {
    val old = this
    new BaseType {
      def First(me:BaseType) = old.First(me)

      def Second(me:BaseType) = old.Second(me)

      override def Second = newSecond()

      def Third(me:BaseType) =
        old.Third(me)
    }
  }


  def Third(me:BaseType): String

  def Third: String = Third(this)

  def setThird(newThird: () => String) = {
    val old = this
    new BaseType {
      def First(me:BaseType) = old.First(me)

      def Second(me:BaseType) = old.Second(me)

      def Third(me:BaseType) = old.Third(me)

      override def Third = newThird()
    }
  }
}

case class TestType(param: String) extends BaseType {
  def First(me:BaseType) =
    "HELLO"

  def Second(me:BaseType) =
    me.First + " WORLD"
  
  def Third(me:BaseType) =
    me.First + " " + me.Second + "!!!"
}

class TestProposed extends Specification {

  val t1 = TestType("")

  val t4 = TestType("").setFirst(()=>"GOODBYE")

  val t5 = t4.setSecond(()=>"YAY")

  val t6 = TestType("").setSecond(()=>"YOO")


  "test new" should {

    // specs wierdness (ambiguious overload) when i try to do
    // t1.Third must beEqualTo("HELLO HELLOW WORLD!!!")
    val basicString:String = t1.Third

    "nothing" in {
      basicString must beEqualTo("HELLO HELLO WORLD!!!")
    }

    "simple test" in {
      t4.Second must beEqualTo("GOODBYE WORLD")
    }

    "harder test" in {
      t4.Third must beEqualTo("GOODBYE GOODBYE WORLD!!!")
    }

    "another test" in {
      t5.Third must beEqualTo("HELLO YAY!!!")
    }

    "yet another test" in {
      t6.Third must beEqualTo("HELLO YOO!!!")
    }

  }

}

class TestOld extends Specification {

  val t1 = OldTestType("")

  val t4 = OldTestType("").setFirst(()=>"GOODBYE")

  val t5 = t4.setSecond(()=>"YAY")

  val t6 = OldTestType("").setSecond(()=>"YOO")


  "test old" should {

    // specs wierdness (ambiguious overload) when i try to do
    // t1.Third must beEqualTo("HELLO HELLOW WORLD!!!")
    val basicString:String = t1.Third

    "nothing" in {
      basicString must beEqualTo("HELLO HELLO WORLD!!!")
    }

    "simple test" in {
      t4.Second must beEqualTo("GOODBYE WORLD")
    }

    "harder test" in {
      t4.Third must beEqualTo("GOODBYE GOODBYE WORLD!!!")
    }

    "another test" in {
      t5.Third must beEqualTo("HELLO YAY!!!")
    }

    "yet another test" in {
      t6.Third must beEqualTo("HELLO YOO!!!")
    }

  }

}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.