6

My XML name in Schema is ref which is a Text field in the Metadata. When I am trying to display this field as

@Component.Metadata.ref

it throws an error:

identifier expected, ref is a keyword

as I am trying to use a keyword - ref

I have tried different options, such as:

<text> @Component.Metadata.ref </text>
@: @Component.Metadata.ref
@{Component.Metadata.ref;}

But still get the same error for each of them.

I tried using one more @ as in C# we use to skip the keyword name:

@Component.Metadata.@@ref

But razor then says:

Argument missing

And with

@Component.Metadata.@@ref 

Razor displays @ref instead of ref value

Could someone please suggest how I can display its value?

The Razor version is 1.2.

  • What type of field is ref in the Schema? – Bart Koopman Dec 12 '13 at 8:56
  • "ref" is a text field in the Metadata. – Meenakshi Dec 12 '13 at 9:01
6

Have you tried:

@Package.GetValue("Component.Metadata.ref")
| improve this answer | |
1

I haven't tested it but I think this would work

@(Component.Metadata.@ref)
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.